ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to Load Combo Box with Named Range (https://www.excelbanter.com/excel-programming/431360-how-load-combo-box-named-range.html)

EricG

How to Load Combo Box with Named Range
 
I have a named range "SNList" on worksheet "SN List". The named range
consists of two columns and 30 rows. I want to fill a combobox (named
"CMB_SN_List") using the contents of the named range. The combobox is set up
with two columns. The combobox is on worksheet "Weekly Data".

What is the proper syntax for that?

I have tried things like:

Worksheets("Weekly Data").OLEObjects("CMB_SN_List").ListFillRange =
Worksheets("SN List").Range("SNList")

but that generates an error. Do I have to use the .AddItem method since I
have more than one column?

Thanks,

Eric


EricG

How to Load Combo Box with Named Range
 
Never mind. It's as simple as

..ListFillRange = "SNList"



Patrick Molloy

How to Load Combo Box with Named Range
 
You're using the ActiveX combobox, so its


Worksheets("SN List").CMB_SN_List.ListFillRange = "SNList"




"EricG" wrote in message
...
I have a named range "SNList" on worksheet "SN List". The named range
consists of two columns and 30 rows. I want to fill a combobox (named
"CMB_SN_List") using the contents of the named range. The combobox is set
up
with two columns. The combobox is on worksheet "Weekly Data".

What is the proper syntax for that?

I have tried things like:

Worksheets("Weekly Data").OLEObjects("CMB_SN_List").ListFillRange =
Worksheets("SN List").Range("SNList")

but that generates an error. Do I have to use the .AddItem method since I
have more than one column?

Thanks,

Eric


EricG

How to Load Combo Box with Named Range
 
Thanks for the reply, Patrick.

One more question - after the user selects whatever from the combbox, I am
using ".Visible = false" to hide it. However, its image stays on the screen.
If I scroll it out of sight and back in, it's gone, which tells me it is
invisible, so the remaining image must be a "ghost".

Is there a neat trick to force a screen redraw to get rid of this "ghost"
image of the combobox?

Thanks,

Eric


Patrick Molloy

How to Load Combo Box with Named Range
 
interesting. maybe do the scroll in vba after setting the visible state?
perhaps turning off screen updating to avoid flicker


"EricG" wrote in message
...
Thanks for the reply, Patrick.

One more question - after the user selects whatever from the combbox, I am
using ".Visible = false" to hide it. However, its image stays on the
screen.
If I scroll it out of sight and back in, it's gone, which tells me it is
invisible, so the remaining image must be a "ghost".

Is there a neat trick to force a screen redraw to get rid of this "ghost"
image of the combobox?

Thanks,

Eric



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

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