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

willow1985

Active Member
Joined
Jul 24, 2019
Messages
320
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
 

DanteAmor

Well-known Member
Joined
Dec 3, 2018
Messages
7,919
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
320
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
7,919
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
320
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
7,919
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
320
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
7,919
Office Version
2007
Platform
Windows
I'm glad to help you. Thanks for the feedback.
 

Forum statistics

Threads
1,078,437
Messages
5,340,277
Members
399,361
Latest member
Linford

Some videos you may like

This Week's Hot Topics

  • Problem with Radio Button's format control
    I am creating an employee evaluation template (a sample is below) Column A is the category Column B, C D, E and F will be ratings (unacceptable...
  • Last Display on userform to a Listbox
    [CODE=vba] lstdisplay.ColumnCount = 15 lstdisplay.RowSource = "A1:O600000" [/CODE] So when i do this it Displays everything on the sheet i am...
  • Rename and move files to a new location
    Dear all, I have an excel file with the following information. The actual file name is at column A but i want to rename it using the following...
  • Help with True/False Formula
    Hello! Am stumped how to fix this formula, in which my result returns 'True', but it should return False. =IF(AG2=True...
  • Clear extra characters from a provided range of cells
    Dear All, I have following code which gives me desired output to remove extra characters from a provided range. But it takes too much time when...
  • Help with Current and highest streaks
    Hi there, I've just joined the forum and this is my first post. I've already spent quite a bit of time searching the net and this forum for a...
Top