I was able to populate my listbox using a range of values from my worksheet. Now I want to populate the cell next to the value selected from the listbox, but it cannot seem to find the original value that is selected from the listbox.
Private Sub cmdAdd_Click()
LastRow = Cells(Rows.Count, 2).End(xlUp).Row
For j = 2 To LastRow
If Cells(j, 2).Value = cmbStage.Value Then
For k = 2 To LastRow
If Cells(k, 3).Value = lstJobCard.Value Then
Cells(k, 4).Value = lstJobCard.Value & ": " & txtNote.Value
End If
Next k
End If
Next j
Unload Me
End Sub
What am I doing wrong?
I figured it out. Rather than saying if that cell value was equal to lstJobCard.Value, I had to say "Like". For example
Private Sub cmdAdd_Click()
LastRow = Cells(Rows.Count, 2).End(xlUp).Row
For j = 2 To LastRow
If Cells(j, 2).Value = cmbStage.Value Then
For k = 2 To LastRow
If Cells(k, 3).Value Like lstJobCard.Value Then
Cells(k, 4).Value = lstJobCard.Value & ": " & txtNote.Value
End If
Next k
End If
Next j
Unload Me
End Sub
Still not sure why, but it works now.