The following code is located in the Userform_Initialise part. DayPB, MidPB and NightPB are all comboboxes that are required to display the same data from the spreadsheet.
This is the code I currently use. Is there any way of simplifying it?
I tried this, but to no avail:
Can anyone tell me the solution?
Code:
With Me.DayPB
For PBNames = 132 To 141
If Range("B" & PBNames).Value <> "" Then
.AddItem Range("B" & PBNames)
Else: Exit For
End If
Next PBNames
.ListIndex = 0
End With
With Me.MidPB
For PBNames = 132 To 141
If Range("B" & PBNames).Value <> "" Then
.AddItem Range("B" & PBNames)
Else: Exit For
End If
Next PBNames
.ListIndex = 0
End With
With Me.NightPB
For PBNames = 132 To 141
If Range("B" & PBNames).Value <> "" Then
.AddItem Range("B" & PBNames)
Else: Exit For
End If
Next PBNames
.ListIndex = 0
End With
This is the code I currently use. Is there any way of simplifying it?
I tried this, but to no avail:
Code:
Call PBChoice(DayPB)
Call PBChoice(MidPB)
Call PBChoice(NightPB)
Sub PBChoice(PB As String)
With Me.PB
For PBNames = 132 To 141
If Range("B" & PBNames).Value <> "" Then
.AddItem Range("B" & PBNames)
Else: Exit For
End If
Next PBNames
.ListIndex = 0
End With
End Sub
Can anyone tell me the solution?