yojoe266
12-04-2017, 02:44 PM
Hi, I'm making a combobox that would auto populate a couple textboxes based on the dropdown menu selection and I keep getting a variable not defined error and I don't know why. I thought I had defined everything. Any help would be nice thanks! : pray2:
Option Explicit
Private Sub cmbNumber_DropButtonClick()
Dim i As Long, LastRow As Long
LastRow = Sheets("Data").Range("A" & Rows.Count).End(xlUp).Row
If Me.cmbNumber.ListCount = 0 Then
For i = 2 To LastRow
Me.cmbNumber.AddItem Sheets("Data").Cells(i, "A").Value
Next i
End If
End Sub
Private Sub cmbNumber_Change()
Dim i As Long
Dim LastRow As Long
LastRow = Sheets("Data").Range("A" & Rows.Count).End(xlUp).Row
For i = 2 To LastRow
If Sheets("Data").Cells(i, "A").Value = (Me.cmbNumber) Or _
Sheets(“Data”).Cells(i, “A”).Value = Val(Me.cmbNumber) Then
Me.TextBox1 = Sheets("Data").Cells(i, "B").Value
Me.TextBox2 = Sheets("Data").Cells(i, "C").Value
End If
Next
End Sub
Option Explicit
Private Sub cmbNumber_DropButtonClick()
Dim i As Long, LastRow As Long
LastRow = Sheets("Data").Range("A" & Rows.Count).End(xlUp).Row
If Me.cmbNumber.ListCount = 0 Then
For i = 2 To LastRow
Me.cmbNumber.AddItem Sheets("Data").Cells(i, "A").Value
Next i
End If
End Sub
Private Sub cmbNumber_Change()
Dim i As Long
Dim LastRow As Long
LastRow = Sheets("Data").Range("A" & Rows.Count).End(xlUp).Row
For i = 2 To LastRow
If Sheets("Data").Cells(i, "A").Value = (Me.cmbNumber) Or _
Sheets(“Data”).Cells(i, “A”).Value = Val(Me.cmbNumber) Then
Me.TextBox1 = Sheets("Data").Cells(i, "B").Value
Me.TextBox2 = Sheets("Data").Cells(i, "C").Value
End If
Next
End Sub