Listbox Values From Cells

Jaye7

Well-known Member
Joined
Jul 7, 2010
Messages
1,060
Can anyone please help with a listbox which contains the values/text of cells A1:B10 and then if any rows in the listbox equals Hello or 1234 it would then run macro named Macro3. Thanks
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.

xenou

MrExcel MVP
Joined
Mar 2, 2007
Messages
16,836
Office Version
  1. 2019
Platform
  1. Windows
Mike has given you the solution to run macros by name. If you want to use "alternative names" then just adapt it for whatever selections (values) you would like to see in the listbox:

http://www.mrexcel.com/forum/showthread.php?t=484232

Note:
A very simple approach would be:
1) Load the listbox with values
2) Use a Select Structure:
Code:
Select Case Listbox1.Value
    Case "Hello" or "1234"
        Application.Run "Macro3"
End Select

If you use a Forms Listbox then you'll probably need to run this code on a change event in the linked cell that is hooked up to the listbox (these are easier to set up and look better so I would go with the forms listboxes).

You can also run macros from the macro dialog box.
 
Last edited:

Jaye7

Well-known Member
Joined
Jul 7, 2010
Messages
1,060
Thanks Xenou,

I will incorporate Mike's example, however, can you please provide a vba script that will put the contents of cells i.e. A1:B10 in the listbox
 

xenou

MrExcel MVP
Joined
Mar 2, 2007
Messages
16,836
Office Version
  1. 2019
Platform
  1. Windows
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,164,683
Messages
5,838,793
Members
430,569
Latest member
sbardelli

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top