Hi
I have a code for a userform with a series of combo boxes that are populated from cell ranges.
I get an error when i try and put the code to populate the combo boxes in the initialize sub. So i had to add them under a new sub acitivate
Is there a way to combine these two subs together? Is it necessary?
Private Sub UserForm_Initialize()
'Variable declaration
Dim IdVal As Integer
'Defining the last row in the Data Sheet ad IdVal
IdVal = fn_LastRow(Sheets("Register"))
'Update next available id on the userform
frmData.txtSEQUENCENUMBER = IdVal
End Sub
Private Sub UserForm_Activate()
'Enters ranges for comboboxes
With Worksheets("LOOKUP")
cmbREV.List = .Range("C1:C" & .Range("C" & .Rows.Count).End(xlUp).Row).Value
cmbAREA.List = .Range("D1:D" & .Range("D" & .Rows.Count).End(xlUp).Row).Value
cmbUNIT.List = .Range("E1:E" & .Range("E" & .Rows.Count).End(xlUp).Row).Value
cmbTYPE1.List = .Range("F1:F" & .Range("F" & .Rows.Count).End(xlUp).Row).Value
cmbTYPE2.List = .Range("G1:G" & .Range("G" & .Rows.Count).End(xlUp).Row).Value
cmbPERSON.List = .Range("H1:H" & .Range("H" & .Rows.Count).End(xlUp).Row).Value
End With
End Sub
I have a code for a userform with a series of combo boxes that are populated from cell ranges.
I get an error when i try and put the code to populate the combo boxes in the initialize sub. So i had to add them under a new sub acitivate
Is there a way to combine these two subs together? Is it necessary?
Private Sub UserForm_Initialize()
'Variable declaration
Dim IdVal As Integer
'Defining the last row in the Data Sheet ad IdVal
IdVal = fn_LastRow(Sheets("Register"))
'Update next available id on the userform
frmData.txtSEQUENCENUMBER = IdVal
End Sub
Private Sub UserForm_Activate()
'Enters ranges for comboboxes
With Worksheets("LOOKUP")
cmbREV.List = .Range("C1:C" & .Range("C" & .Rows.Count).End(xlUp).Row).Value
cmbAREA.List = .Range("D1:D" & .Range("D" & .Rows.Count).End(xlUp).Row).Value
cmbUNIT.List = .Range("E1:E" & .Range("E" & .Rows.Count).End(xlUp).Row).Value
cmbTYPE1.List = .Range("F1:F" & .Range("F" & .Rows.Count).End(xlUp).Row).Value
cmbTYPE2.List = .Range("G1:G" & .Range("G" & .Rows.Count).End(xlUp).Row).Value
cmbPERSON.List = .Range("H1:H" & .Range("H" & .Rows.Count).End(xlUp).Row).Value
End With
End Sub