Fill out combo box until empty cell

leok3

New Member
Joined
May 5, 2011
Messages
4
Hi, I need to fill out a combo box with data from a column but only until it finds an empty cell.

The code I'm using at the moment is:

For Each rngCell In rngClients
'display on the list
If rngCell <> "" Then
cboCustomerList.AddItem rngCell.Value
End If
Next rngCell


It works, but it actually is looking though all the cells, so it takes the User Form a little while to load.
Is it possible to do this using a loop but not to go though every single cell?

Thanks
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
Hello and Welcome,

You can add an Else statement that instructs the code to Exit the For...Next loop when the first empty cell is found.
Rich (BB code):
For Each rngCell In rngClients
'display on the list
    If rngCell <> "" Then
        cboCustomerList.AddItem rngCell.value
    Else
      Exit For
    End If
Next rngCell
 
Upvote 0

Forum statistics

Threads
1,224,579
Messages
6,179,656
Members
452,934
Latest member
mm1t1

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