Record macro to include changes in dropdowns

G

Guest

Hi,
I am a relatively new user of macros, and I am trying to write one which
changes the selection in dropdown boxes. I can create the dropdowns via Data
| Validation or the Forms toolbar. Example, the 1st dropdown contains
Selection 1 and Selection 2 as options, and the 2nd dropdown contains Event 1
and Event 2 as options. I am trying to write one macro that would change the
dropdowns to select Selection 1 and Event 2, and another macro that would
change the dropdowns to show Selection 2 and Event 1. Thank you for the help.
Graeme
 
G

Guest

You would just write the appropriate value to the cell that contains the data
validation.

for illustration purposes, I will assume that on the activesheet, the
selection dropdown is in B9 and the Event dropdown is in C9. Then you would
use code like this.

Sub macro1
Range("B9").Value = "Selection 1"
Range("C9").Value = "Event 2"
End Sub

Sub macro2
Range("B9").Value = "Selection 2"
Range("C9").Value = "Event 1"
End Sub

an alternative approach

Sub Macro1()
Range("B9:C9").Vaue = Array("Selection 1","Event 2")
End Sub

Sub Macro2()
Range("B9:C9").Vaue = Array("Selection 2","Event 1")
End Sub
 
G

Guest

Tom,

Thanks for that great tip again! I mentioned this a few years back: It's
time to put your wealth of knowledge into a book, so we all can have a "Tom"
of our own next to our keyboard.

Thanks,

Ben
 
G

Guest

There are some great books out there already. I would just be diluting the
market, but thanks for the support. The advantage of doing it here is there
is a better "index" and the suggestions are more specifically focused. <g>
 
G

Guest

Tom - thank you.

Tom Ogilvy said:
There are some great books out there already. I would just be diluting the
market, but thanks for the support. The advantage of doing it here is there
is a better "index" and the suggestions are more specifically focused. <g>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top