Excel macro
|
Original Message
|
Name: AlwaysWillingToLearn
Date: July 25, 2007 at 07:39:46 Pacific
Subject: Excel macroOS: winxp proCPU/Ram: p4Model/Manufacturer: msi |
Comment: hello, i have created a drop down menu using validation form the data menu. i have created a list of items i want to populate my list with and have assigned the source to it. what i want to do it make a button which can swich from one datasource to another for this dropdown for example if range A1 has the drop down when i press button1 the dropdown has a b c when i press button2 the dropdown has d e f any ideas please? Thanks,
Report Offensive Message For Removal
|
|
Response Number 1
|
Name: DerbyDad03
Date: July 25, 2007 at 09:49:12 Pacific
|
Reply: (edit)If you record a macro while setting up your validation, you'll get something like the code below. Make a copy of the recorded code, then change the names and the ranges they refer to. (See my '*** lines.) Assign each macro to it's own button and click to your heart's content. Sub Button1() '*** You'll need another copy of this code called something like Sub Button2() With Selection.Validation '*** Change the above line to read With Range("A1").Validation .Delete .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _ xlBetween, Formula1:="=$K$1:$K$7" '*** In the Button2 code change the last part to be Formula1:="=$L$1:$L$7" .IgnoreBlank = True .InCellDropdown = True .InputTitle = "" .ErrorTitle = "" .InputMessage = "" .ErrorMessage = "" .ShowInput = True .ShowError = True End With End Sub
Report Offensive Follow Up For Removal
|
Use following form to reply to current message: