So, I have 3 combo boxes on a form. 1 is populated when the form loads, one is populated when the user picks a value from the first combo box, and the third is populated when the user picks a value form the 2nd.
when the 3rd combo box is changed, I am using a nested if statement to determine what row this combination lies in (so I can populate textboxes on the form). However, the first If Statement is failing to trigger (ie return a 'true' value). there is an acceptable value in the cell, so it should progress to the next if statement, but it just jumps to the end of my While statement.
Private Sub cmb_State_Change()
Dim Project, licence, state As String
Dim selectedrow As Integer
Dim LastRow As Integer
Dim i, j As Integer
selededrow = 0
Project = cmb_Project.Value
licence = cmb_Licence.Value
state = cmb_State.Value
i = 1
j = 3
While selectedrow = 0
If Worksheets("Entitlements").Cells(i, j) = Project Then
i = i + 6
If Worksheets("Entitlements").Cells(i, j) = licence Then
i = i - 1
If Worksheets("Entitlements").Cells(i, j) = state Then
selectedrow = j
End If
End If
Else
j = j + 1
i = i - 5
End If
Wend
End Sub
Can anybody see why it would be behaving like this?
Thanks.
Aucun commentaire:
Enregistrer un commentaire