Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Dynamically Activate a Combo Box

I know how to use VBA to activate a combo box by hard-coding the name (for
example, ComboBox1.Activate). But how do I activate a combo box when its
name can only be determined at run time?

On a worksheet, each of the first 100 cells in column B sits underneath a
combo box from the controls toolbar. The combo box names go down the column
like this:
Combo_B1
Combo_B2
Combo_B3...

So I can dynamically build the name of the appropriate combo box when the
cursor is located in the underlying cell:

Dim myComboName As String
myComboName = "Combo_" & ActiveCell.Address(0, 0)

What do I need to do now to activate this combo box? I think I might know
how to do it by looping through all of the controls on the sheet looking for
the one that matches the name I've constructed. But I'm hoping for more
direct and efficient method.

Thanks.





  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Dynamically Activate a Combo Box

ActiveSheet.OLEObjects(mycomboname).Activate



Greg Hoffman wrote:

I know how to use VBA to activate a combo box by hard-coding the name (for
example, ComboBox1.Activate). But how do I activate a combo box when its
name can only be determined at run time?

On a worksheet, each of the first 100 cells in column B sits underneath a
combo box from the controls toolbar. The combo box names go down the column
like this:
Combo_B1
Combo_B2
Combo_B3...

So I can dynamically build the name of the appropriate combo box when the
cursor is located in the underlying cell:

Dim myComboName As String
myComboName = "Combo_" & ActiveCell.Address(0, 0)

What do I need to do now to activate this combo box? I think I might know
how to do it by looping through all of the controls on the sheet looking for
the one that matches the name I've constructed. But I'm hoping for more
direct and efficient method.

Thanks.


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Dynamically Activate a Combo Box

Perfect...thanks.


"Dave Peterson" wrote in message
...
ActiveSheet.OLEObjects(mycomboname).Activate



Greg Hoffman wrote:

I know how to use VBA to activate a combo box by hard-coding the name
(for
example, ComboBox1.Activate). But how do I activate a combo box when its
name can only be determined at run time?

On a worksheet, each of the first 100 cells in column B sits underneath a
combo box from the controls toolbar. The combo box names go down the
column
like this:
Combo_B1
Combo_B2
Combo_B3...

So I can dynamically build the name of the appropriate combo box when the
cursor is located in the underlying cell:

Dim myComboName As String
myComboName = "Combo_" & ActiveCell.Address(0, 0)

What do I need to do now to activate this combo box? I think I might
know
how to do it by looping through all of the controls on the sheet looking
for
the one that matches the name I've constructed. But I'm hoping for more
direct and efficient method.

Thanks.


--

Dave Peterson



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
Can a combo box activate different macros Carrie Excel Discussion (Misc queries) 1 June 5th 06 06:34 PM
Dynamically Add Combo Boxes AP Excel Programming 1 September 8th 05 12:37 AM
dynamically assigning to a combo box C[_3_] Excel Programming 1 February 22nd 05 08:30 AM
Create combo box dynamically Duraiswamy Lingappan Excel Programming 9 July 8th 04 05:09 PM
how to add a combo box in to a excel cell using VBA dynamically? Gamini Jayarathne Excel Programming 1 May 7th 04 11:57 AM


All times are GMT +1. The time now is 06:20 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"