Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Combobox | Add items | Object Required


I have several Combo boxes setup on my spread sheet with the following
naming conventions:

COMBO_<VARIABLE_<VARIABLE

So for example, one of my combo boxes is called: COMBO_1_1

Depending on certain criteria I want to populate one of the combo
boxes:

COMBO_1_1
COMBO_1_2
COMBO_1_3

What I can't figure out is how to reference my combo box as an object.

I could write the code like:

COMBO_1_1.AddItem "1 - Pizza"
COMBO_1_1.AddItem "2 - Chinese Food"

I want my code to be more dynamic than that though. I want to be able
to have variables where the numbers a

Dim i As Integer, x As Integer

i = 1
x = 1

COMBO_i_x.AddItem "1 - Pizza"
COMBO_i_x.AddItem "2 - Chinese Food"


If anyone can help me with this I would be much obliged.


--
gduron
------------------------------------------------------------------------
gduron's Profile: http://www.excelforum.com/member.php...o&userid=33239
View this thread: http://www.excelforum.com/showthread...hreadid=537912

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Combobox | Add items | Object Required

Dim cbox as MSForms.Combobox
Dim ole as OleObject
Dim x as Long, i as Long

i = 1
x = 1

set ole = Activesheet.OleObjects("Combo_" & i & "_" & x)
set cbox = ole.Object
cbox.AddItem "1 - Pizza"
cbox.AddItem "2 - Chinese Food"

--
Regards,
Tom Ogilvy


"gduron" wrote in
message ...

I have several Combo boxes setup on my spread sheet with the following
naming conventions:

COMBO_<VARIABLE_<VARIABLE

So for example, one of my combo boxes is called: COMBO_1_1

Depending on certain criteria I want to populate one of the combo
boxes:

COMBO_1_1
COMBO_1_2
COMBO_1_3

What I can't figure out is how to reference my combo box as an object.

I could write the code like:

COMBO_1_1.AddItem "1 - Pizza"
COMBO_1_1.AddItem "2 - Chinese Food"

I want my code to be more dynamic than that though. I want to be able
to have variables where the numbers a

Dim i As Integer, x As Integer

i = 1
x = 1

COMBO_i_x.AddItem "1 - Pizza"
COMBO_i_x.AddItem "2 - Chinese Food"


If anyone can help me with this I would be much obliged.


--
gduron
------------------------------------------------------------------------
gduron's Profile:

http://www.excelforum.com/member.php...o&userid=33239
View this thread: http://www.excelforum.com/showthread...hreadid=537912



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
Object Required Jim Thomlinson Excel Programming 0 March 26th 06 11:46 PM
Object required? Tony Excel Programming 2 March 22nd 05 04:52 PM
VBA Help Required - Copying details from ComboBox onto worksheet Alan T[_4_] Excel Programming 1 August 25th 04 06:14 PM
Object required. y Excel Programming 1 April 10th 04 10:50 AM
Userform text & combobox population help required please Newbie1 Excel Programming 5 February 28th 04 05:19 PM


All times are GMT +1. The time now is 09:29 PM.

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

About Us

"It's about Microsoft Excel"