title: Excel VBA: Userfom - textbox value depends on combobox value
body: <p>I am creating userform which I will be using to insert data and then make some other stuff. </p>
  
  <p>I have a Userform with ComboBox and few TextBoxes. ComboBox is filled with data from range. I want to change values of TextBoxes depending on ComboBox value. Values of TextBoxes should be filled with specific values from worksheet. I thought about creating For Each loop to determine Row of chosen ComboBox value and then change TextBoxes using Row number and setting proper offset.</p>
  
  <p>Worksheet is table with headers and filled with data such as name, city etc.</p>
  
  <p>However my code does not work within Userform. </p>
  
  <p>Any ideas what is wrong or maybe a different approach to a problem?</p>
  
  <p>klient = ComboBox name</p>
  
  <pre><code>Private Sub klient_Change()
  
  Dim MyCell As Range, MyRange As Range
  Dim wiersz As Long
  
  Set MyRange = Range("klienci")
  
  For Each MyCell In MyRange
      If klient.Value = MyCell.Value Then
      wiersz = MyCell.Value
      Exit For:
      End If
  Next
  
  MsgBox (wiersz)
  
  End Sub
  </code></pre>