Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default Userform Combobox

Hi,

I have a userform that contains a combobox, I thought I could add a range to
the additem i.e.

With ComboBox1
.AddItem MyList
End With

where MyList is a range that is present on a worksheet.

Thanks

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Userform Combobox

me.combobox1.list = myRng.value
(where myRng is a range)

or
me.combobox1.list = myList
(where myList is an array of values)



Excel User wrote:

Hi,

I have a userform that contains a combobox, I thought I could add a range to
the additem i.e.

With ComboBox1
.AddItem MyList
End With

where MyList is a range that is present on a worksheet.

Thanks


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default Userform Combobox

Dave,

I'm alittle lost, I've tried :

Dim myRng As Range
myRng = myRange.Value

'where myRange is a named range on a sheet named 'item list'

ComboBox.List = myRng

but I get an error message.


Run-time error '424'
Object required

Not sure what I am doing wrong?

"Dave Peterson" wrote in message
...
me.combobox1.list = myRng.value
(where myRng is a range)

or
me.combobox1.list = myList
(where myList is an array of values)



Excel User wrote:

Hi,

I have a userform that contains a combobox, I thought I could add a range
to
the additem i.e.

With ComboBox1
.AddItem MyList
End With

where MyList is a range that is present on a worksheet.

Thanks


--

Dave Peterson


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Userform Combobox

I forgot to add that I assumed you are putting the code into the UserForm
code module, maybe in the initialize event. It won't work from the standard
code module1 unless the UserForm is open while the code runs and that is
another whole scenario.

"Excel User" wrote:

Dave,

I'm alittle lost, I've tried :

Dim myRng As Range
myRng = myRange.Value

'where myRange is a named range on a sheet named 'item list'

ComboBox.List = myRng

but I get an error message.


Run-time error '424'
Object required

Not sure what I am doing wrong?

"Dave Peterson" wrote in message
...
me.combobox1.list = myRng.value
(where myRng is a range)

or
me.combobox1.list = myList
(where myList is an array of values)



Excel User wrote:

Hi,

I have a userform that contains a combobox, I thought I could add a range
to
the additem i.e.

With ComboBox1
.AddItem MyList
End With

where MyList is a range that is present on a worksheet.

Thanks


--

Dave Peterson



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Userform Combobox

If myRange is a named range, then try:

me.combobox1.list = worksheets("item list").range("myRange").value

or

dim myRng as range
set myrng = worksheets("item list").range("myRange")
me.combobox1.list = myrng.value

or

dim myList as variant
mylist = worksheets("item list").range("myRange").value
my.combobox1.list = mylist




Excel User wrote:

Dave,

I'm alittle lost, I've tried :

Dim myRng As Range
myRng = myRange.Value

'where myRange is a named range on a sheet named 'item list'

ComboBox.List = myRng

but I get an error message.

Run-time error '424'
Object required

Not sure what I am doing wrong?

"Dave Peterson" wrote in message
...
me.combobox1.list = myRng.value
(where myRng is a range)

or
me.combobox1.list = myList
(where myList is an array of values)



Excel User wrote:

Hi,

I have a userform that contains a combobox, I thought I could add a range
to
the additem i.e.

With ComboBox1
.AddItem MyList
End With

where MyList is a range that is present on a worksheet.

Thanks


--

Dave Peterson


--

Dave Peterson


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default Userform Combobox

Thanks Dave and JLGWhiz,

I've got it know!

"Dave Peterson" wrote in message
...
If myRange is a named range, then try:

me.combobox1.list = worksheets("item list").range("myRange").value

or

dim myRng as range
set myrng = worksheets("item list").range("myRange")
me.combobox1.list = myrng.value

or

dim myList as variant
mylist = worksheets("item list").range("myRange").value
my.combobox1.list = mylist




Excel User wrote:

Dave,

I'm alittle lost, I've tried :

Dim myRng As Range
myRng = myRange.Value

'where myRange is a named range on a sheet named 'item list'

ComboBox.List = myRng

but I get an error message.

Run-time error '424'
Object required

Not sure what I am doing wrong?

"Dave Peterson" wrote in message
...
me.combobox1.list = myRng.value
(where myRng is a range)

or
me.combobox1.list = myList
(where myList is an array of values)



Excel User wrote:

Hi,

I have a userform that contains a combobox, I thought I could add a
range
to
the additem i.e.

With ComboBox1
.AddItem MyList
End With

where MyList is a range that is present on a worksheet.

Thanks

--

Dave Peterson


--

Dave Peterson


  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Userform Combobox

You can write it a couple of ways:

Me.ComboBox1.List = myRng

or:

UserForm1.ComboBox1.List = myRng

the user form has to be included to tell the compiler where to look for the
combobox. Also you have to tell it which combobox you are referring to.
Tthe control name must be specific so VBA knows which one to look at. As you
add and delete controls, VBA will automatically name them sequentially, but
you can change the names to something more recognizable by you that maybe
tells you what the control does. You can then use that name in your code
instead of combobox1, combobox2, etc.

"Excel User" wrote:

Dave,

I'm alittle lost, I've tried :

Dim myRng As Range
myRng = myRange.Value

'where myRange is a named range on a sheet named 'item list'

ComboBox.List = myRng

but I get an error message.


Run-time error '424'
Object required

Not sure what I am doing wrong?

"Dave Peterson" wrote in message
...
me.combobox1.list = myRng.value
(where myRng is a range)

or
me.combobox1.list = myList
(where myList is an array of values)



Excel User wrote:

Hi,

I have a userform that contains a combobox, I thought I could add a range
to
the additem i.e.

With ComboBox1
.AddItem MyList
End With

where MyList is a range that is present on a worksheet.

Thanks


--

Dave Peterson



  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Userform Combobox

If you used AddItem or List to initially load your combobox, you should be
able to add additional items using the AddItem method. However, if you
initially loaded your combobox using RowSource or ListFillRange, then you
cannot use AddItem to amend the current list.

"Excel User" wrote:

Hi,

I have a userform that contains a combobox, I thought I could add a range to
the additem i.e.

With ComboBox1
.AddItem MyList
End With

where MyList is a range that is present on a worksheet.

Thanks


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
combobox in userform bernd Excel Programming 1 June 15th 07 02:12 AM
combobox and userform help! dawn Excel Programming 3 October 11th 06 02:08 AM
Userform w/ComboBox D.Parker Excel Discussion (Misc queries) 2 May 6th 05 04:28 PM
ComboBox on UserForm Michel[_4_] Excel Programming 3 August 1st 04 11:10 PM
ComboBox on UserForm Michel[_4_] Excel Programming 2 July 31st 04 10:11 PM


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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"