Update List box

Swaroon

Active Member
Joined
Nov 18, 2005
Messages
288
Office Version
  1. 365
Hi,
I have a list box that needs to be set to option 2 before running a macro, here's the main piece of code I am trying to kick off but I can't work out what the command should be eg. I tried and failed with Application.Run

.cboSegments.ListIndex = 2

thanks
Steve
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
Should this procedure run when the listbox is changed? If so, add this to the change event for it:

if .cboSegments.ListIndex = 2 then call MyMacro
 
Upvote 0
Thanks for this, I'll check it out, but maybe I didnt explain properly.

The macro runs by clicking a button, the first command is to ensure that the list box option 2 is selected which is what the code i posted is supposed to do, then it runs the remainer of the macro - what I cant work out is what code is required to get the select option 2 in the list box piece to work.

Thanks for your help

cheers
Steve
 
Upvote 0
Sorry, not getting it.

To clarify (for me), you have a listbox called cboSegments and you have it populated with a list of items. If they select the item corresponding to ListItem 2 and press the run button, you want the macro to work, is that it? If so, my code should work, you just put that code in the click event for the run button.
 
Upvote 0
Great, I understand now, I'd put the code in the wrong place - module not the click event for the button.

thanks for your help
cheers
 
Upvote 0
Also, be careful that you want ListIndex 2 which is the third in the list. The ListIndex usually counts from 0.
 
Upvote 0

Forum statistics

Threads
1,224,566
Messages
6,179,555
Members
452,928
Latest member
101blockchains

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
Back
Top