Determine the lastrow of the Column you're interested in.
Private Sub Userform_Initialize
Dim WS As Worksheet
Dim LastRow As Long
Dim C As Range
Set WS = Worksheets("Amends")
With WS
'Last row with data in column A.
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
Then you iterate the range and stuff the data into the combobox.
'The data starts on row 3
For A = 3 to LastRow
combobox8.additem WS.range("A" & A)
'Use this loop to also fill any other combobox
combobox9.additem WS.range("B" & A)
next
end with
This is a brute force method. It doesn't check for duplicates. Whatever it finds in the range, it adds it.
If the Halls, for instance, are static and don't change, then you can hard code those in.
combobox8.additem "Smith Hall"
combobox8.additem "Jones Hall"
combobox8.additem "Baron Hall"
As far as combining the userforms, add a frame and inside that frame add three optionbuttons.
By selecting the appropriate optionbutton, you can carry out the necessary function. We can guide this selection by testing which option is selected and take the required action. We can even preselect the correct option based on the activex button that was pushed on the sheet.
Private Sub Userform_Initialize
A = Application.Caller
if A = "Button 5" then optModify = True
Then when the Ok button is selected, we, again, test the optionbutton and perform the required action.
Bookmarks