VBA code to select an item from an Active X combo box

willow1985

Active Member
Joined
Jul 24, 2019
Messages
499
Office Version
2019
Platform
Windows
Hello,

I am looking for the VBA code that would select from a combo box the item that says "ALL".

It is cell reference A21 on a seperate sheet called "List"

I hope someone can help me.

Thank you

Carla
 

Some videos you may like

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.

DanteAmor

Well-known Member
Joined
Dec 3, 2018
Messages
11,678
Office Version
2007
Platform
Windows
Is the data "All" already loaded in the combo?
When do you want to select the "All" data, when you open the book?
Or what moment?
 

willow1985

Active Member
Joined
Jul 24, 2019
Messages
499
Office Version
2019
Platform
Windows
my List fill Range is A1:A255. The Word "ALL" is A21 on the list.

I put a button on the sheet called "Refresh" that runs a Macro I made to refresh all the data.
When the Macro runs I would like to add some code to have the combo box selection change to "ALL".
My bosses want to look at "ALL" data first after running the Macro (refreshing the data).
 

DanteAmor

Well-known Member
Joined
Dec 3, 2018
Messages
11,678
Office Version
2007
Platform
Windows
When the Macro runs I would like to add some code to have the combo box selection change to "ALL".
At the end of your code add:

Code:
ComboBox1.value = "ALL"
 

willow1985

Active Member
Joined
Jul 24, 2019
Messages
499
Office Version
2019
Platform
Windows
I get Run-time error '424': Object required

I only have the one combo box and it is named ComboBox1
It is an ActiveX ComboBox (not sure if this makes a difference in the code)

Thank you

Carla
 

DanteAmor

Well-known Member
Joined
Dec 3, 2018
Messages
11,678
Office Version
2007
Platform
Windows
Try

Code:
[COLOR=#0000ff]ActiveSheet[/COLOR].ComboBox1.Value = "All"
If you have problems, you can put all your code here.
What version of Excel do you have?
 

willow1985

Active Member
Joined
Jul 24, 2019
Messages
499
Office Version
2019
Platform
Windows
This worked perfectly, thank you soooo much!
My sheet was due and this was the last piece I just couldn't get to work and I knew it was something simple. You really saved me, thank you again :):)
 

DanteAmor

Well-known Member
Joined
Dec 3, 2018
Messages
11,678
Office Version
2007
Platform
Windows
I'm glad to help you. Thanks for the feedback.
 

Watch MrExcel Video

Forum statistics

Threads
1,098,857
Messages
5,465,102
Members
406,412
Latest member
superjoejoe

This Week's Hot Topics

Top