setting vairable rowsource property

chiplonkar

New Member
Joined
Jan 17, 2011
Messages
2
I have an user form with a combobox. I want to set the dropdown list. If I set it through the properties of the combobox, it is a fixed length dropdown list. i.e. combobox2.rowsource="A1:A18" has eighteen cells in coumn "A". I want to make the figure 18 as a variable depending upon the number of entries in the column A. I tried combobox2.rowsource="A1:A&m"
wher m is an integer varibale. It does not work. Can anyone suggest the correct syntax?
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
Hi and welcome.

Here is one way it could be done.

Code:
Private Sub UserForm_Initialize()

    Dim cell As Range
    
    ComboBox1.RowSource = ""
    ComboBox1.Clear
    
    With Sheets("Sheet1")
        For Each cell In .Range("A1", .Range("A" & Rows.Count).End(xlUp))
            ComboBox1.AddItem cell.Value
        Next cell
    End With
    
End Sub
 
Upvote 0
Great! It worked !! Thank you very much. I think you have faced this situation of having a variable length of dropdown earlier !! Thanks again.
 
Upvote 0

Forum statistics

Threads
1,216,100
Messages
6,128,827
Members
449,470
Latest member
Subhash Chand

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top