Hi,
I'm kinda new to VBA and having a little problem with this code.
On some point it's not generating my data in the text box, based on my drop down list.
But if I change my range to ("A"), It's working. Any help would be appreciate. Thank youu
Below is my code.
I'm kinda new to VBA and having a little problem with this code.
On some point it's not generating my data in the text box, based on my drop down list.
But if I change my range to ("A"), It's working. Any help would be appreciate. Thank youu
Below is my code.
VBA Code:
Dim i As Long, LastRow As Long, ws As Worksheet
Set ws = Sheets("Sheet2")
LastRow = ws.Range("B" & Rows.Count).End(xlUp).Row
For i = 2 To LastRow
If Val(Me.ComboBox1.Value) = ws.Cells(i, "B") Then
Me.TextBox2 = ws.Cells(i, "A").Value
Me.TextBox3 = ws.Cells(i, "B").Value
Me.TextBox4 = ws.Cells(i, "C").Value
Me.TextBox5 = ws.Cells(i, "D").Value
End If
Next i
End Sub
Private Sub UserForm_Initialize()
Dim i As Long, LastRow As Long, ws As Worksheet
Set ws = Sheets("Sheet2")
LastRow = ws.Range("B" & Rows.Count).End(xlUp).Row
For i = 2 To LastRow
Me.ComboBox1.AddItem ws.Cells(i, "B").Value
Next i
End Sub