Expanding a list for combobox

AnnetteTR

Board Regular
Joined
Aug 19, 2010
Messages
85
Hi
I am making a userform where you enter "room number", "airvolume" and the name for a "ventilation unit".

I want to make the input for the ventilations unit as a Combobox.
When you start the list i empty - as you haven't defined any yet.
But when you enter the next room it must be possible to either choose one of the previous used or ad a new name.

How can that be done?

Regards
Annette
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
Hi
In order to do so I define a named range on Sheet1 called rngVentUnit
with:
Code:
 =OFFSET(Sheet1!$A$1;0;0;COUNTA(Sheet1!$A:$A);1)

On a Userform I define a Combobox called cbxVentUnit
in the code for the userform I use this:
Code:
Private Sub UserForm_Initialize()
With cbxVentUnit
        .RowSource = Sheet1.Range("rngVentUnit").Address
        .ListIndex = 0
    End With
End Sub

This works fine.

When I take this code and use it in a bigger Userform called frmUserInput which has 4 comboboxes and a lot of textboxes it doesn't work.

I have tried to put in the Private Sub UserForm_Activate()
this gives the fault:
"Method 'Range' of object'_Worksheet' failed
and debug points at :
Code:
     .RowSource = Sheet1.Range("rngVentUnit").Address

and in the Private Sub UserForm_Initialize() this gives the fault:
"Method 'Range' of object'_Worksheet' failed
and debug points at the call of the userform

The other comboboxes works fine and they have fixed ranges.

So the first step of the way is to get the named range to work.
Help Please.

Regards Annette
 
Upvote 0
Hi Andrew
Thank you - now that part works.
I found a thread about expanding the list - I will try that before I return.

Regards Annette
 
Upvote 0

Forum statistics

Threads
1,216,759
Messages
6,132,548
Members
449,735
Latest member
Gary_M

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