ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Help needed - populating comboboxes from list?? (https://www.excelbanter.com/excel-programming/381489-re-help-needed-populating-comboboxes-list.html)

merjet

Help needed - populating comboboxes from list??
 
Here is code for the UserForm to populate ComboBox1. I leave ComboBox2
for you. Use the Properties Window to set the ColumnCount and
ColumnWidths properties. I set ColumnHeads to False. It may not be
possible to use column headings when you are skipping some columns and
rows in the source area.

Private Sub UserForm_Activate()
Dim rng As Range
Dim iRow As Integer
Dim iCt As Integer

iRow = Sheets("Sheet1").Range("A1").End(xlDown).Row
Set rng = Sheets("Sheet1").Range("A2:A" & iRow)
For Each c In rng
If c.Offset(0, 4) < "" And c.Offset(0, 5) = "" Then
iCt = iCt + 1
ComboBox1.AddItem c
ComboBox1.Column(1, iCt - 1) = c.Offset(0, 2)
ComboBox1.Column(2, iCt - 1) = c.Offset(0, 3)
End If
Next c
End Sub

HTH,
Merjet



All times are GMT +1. The time now is 12:12 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com