ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Record macro to include changes in dropdowns (https://www.excelbanter.com/excel-programming/384933-record-macro-include-changes-dropdowns.html)

Graeme

Record macro to include changes in dropdowns
 
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

Tom Ogilvy

Record macro to include changes in dropdowns
 
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

--
Regards,
Tom Ogilvy

"Graeme" wrote:

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


Ben

Record macro to include changes in dropdowns
 
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



--



"Tom Ogilvy" wrote:

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

--
Regards,
Tom Ogilvy

"Graeme" wrote:

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


Tom Ogilvy

Record macro to include changes in dropdowns
 
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

--
Regards,
Tom Ogilvy


"Ben" wrote:

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



--



"Tom Ogilvy" wrote:

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

--
Regards,
Tom Ogilvy

"Graeme" wrote:

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


Graeme

Record macro to include changes in dropdowns
 
Tom - thank you.

"Tom Ogilvy" wrote:

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

--
Regards,
Tom Ogilvy


"Ben" wrote:

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



--



"Tom Ogilvy" wrote:

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

--
Regards,
Tom Ogilvy

"Graeme" wrote:

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



All times are GMT +1. The time now is 12:27 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com