4,375 questions
In case of User Forms, check an example:
Dim cb As ComboBox
Set cb = Controls("CB1") ' or Controls("CB" & Counter)
Dim v As String
v = cb.Value
MsgBox v
If it works, integrate it to your loop.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Can't figure out how to use a variable for a combo box in the following code. Goal is to get the loop to loop through the combo box names and check if they are empty. Had this functioning with an Array of all the combo box names.
Private Sub PrelimPermitSub_Click()
Dim Counter As Long
Counter = 1
Do While Counter < 16
Dim yy As String
yy = "CB" & Counter
MsgBox (yy)
If ww.Value = "" Then
MsgBox ("Please complete forms in all tabs.")
Exit Do
Else
Dim cnum As String
cnum = 30 + Counter
cell = "D" + cnum
Sheets("Backend").Range(cell).Value = ww.Value
End If
Counter = Counter + 1
Loop
End Sub
In case of User Forms, check an example:
Dim cb As ComboBox
Set cb = Controls("CB1") ' or Controls("CB" & Counter)
Dim v As String
v = cb.Value
MsgBox v
If it works, integrate it to your loop.