Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Validation List Question
I have a data validation list with a number of states in it. Each time I
select a new state I want 2 macros to run. The list is in cell A4 of Sheet 1. Here is the code I am using at the worksheet level, can someone tell me what I'm doing wrong? Private Sub Worksheet_Change(ByVal Target As Range) If Target.Address = "A4" Then pp_maj_macro pp_minor_macro End If End Sub Thanks so much, Dave |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Validation List Question
Target.Address will return $A$4.
You could use: If Target.Address = "$A$4" Then or If Target.Address(0,0) = "A4" Then or (what I like) if intersect(target,me.range("a4")) is nothing then exit sub I find the last one easiest to modify (for multiple cells/ranges). "dave!!" wrote: I have a data validation list with a number of states in it. Each time I select a new state I want 2 macros to run. The list is in cell A4 of Sheet 1. Here is the code I am using at the worksheet level, can someone tell me what I'm doing wrong? Private Sub Worksheet_Change(ByVal Target As Range) If Target.Address = "A4" Then pp_maj_macro pp_minor_macro End If End Sub Thanks so much, Dave -- Dave Peterson |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Validation List Question
If Target.Address = "$A$4" Then
or If Target.Address(0,0) = "A4" Then -- Regards, Tom Ogilvy "dave!!" wrote in message ... I have a data validation list with a number of states in it. Each time I select a new state I want 2 macros to run. The list is in cell A4 of Sheet 1. Here is the code I am using at the worksheet level, can someone tell me what I'm doing wrong? Private Sub Worksheet_Change(ByVal Target As Range) If Target.Address = "A4" Then pp_maj_macro pp_minor_macro End If End Sub Thanks so much, Dave |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Validation List Question
I tried the first 2...but they're not working.
"Dave Peterson" wrote in message ... Target.Address will return $A$4. You could use: If Target.Address = "$A$4" Then or If Target.Address(0,0) = "A4" Then or (what I like) if intersect(target,me.range("a4")) is nothing then exit sub I find the last one easiest to modify (for multiple cells/ranges). "dave!!" wrote: I have a data validation list with a number of states in it. Each time I select a new state I want 2 macros to run. The list is in cell A4 of Sheet 1. Here is the code I am using at the worksheet level, can someone tell me what I'm doing wrong? Private Sub Worksheet_Change(ByVal Target As Range) If Target.Address = "A4" Then pp_maj_macro pp_minor_macro End If End Sub Thanks so much, Dave -- Dave Peterson |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Validation List Question
I put a message box in to verify that it's getting past the if statement,
and that's working fine, but the macros aren't running. Any thoughts? Thanks, Dave "Tom Ogilvy" wrote in message ... If Target.Address = "$A$4" Then or If Target.Address(0,0) = "A4" Then -- Regards, Tom Ogilvy "dave!!" wrote in message ... I have a data validation list with a number of states in it. Each time I select a new state I want 2 macros to run. The list is in cell A4 of Sheet 1. Here is the code I am using at the worksheet level, can someone tell me what I'm doing wrong? Private Sub Worksheet_Change(ByVal Target As Range) If Target.Address = "A4" Then pp_maj_macro pp_minor_macro End If End Sub Thanks so much, Dave |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
Validation List Question
I put a data validation dropdown in cell A4 and filled it from a list of
states in another column then right clicked on the sheet tab and selected view code. I pasted in this: Private Sub Worksheet_Change(ByVal Target As Range) If Target.Address = "$A$4" Then 'pp_maj_macro 'pp_minor_macro MsgBox Target.Address End If End Sub then went back to excel and selected a state. Worked fine for me xl2003. If you are using xl97, this situation does not trigger the change event. Another possibility is that you have code that disables events. sub ReEnableEvents() Application.EnableEvents = True End sub Put in a general module and run it. -- Regards, Tom Ogilvy "dave!!" wrote in message ... I tried the first 2...but they're not working. "Dave Peterson" wrote in message ... Target.Address will return $A$4. You could use: If Target.Address = "$A$4" Then or If Target.Address(0,0) = "A4" Then or (what I like) if intersect(target,me.range("a4")) is nothing then exit sub I find the last one easiest to modify (for multiple cells/ranges). "dave!!" wrote: I have a data validation list with a number of states in it. Each time I select a new state I want 2 macros to run. The list is in cell A4 of Sheet 1. Here is the code I am using at the worksheet level, can someone tell me what I'm doing wrong? Private Sub Worksheet_Change(ByVal Target As Range) If Target.Address = "A4" Then pp_maj_macro pp_minor_macro End If End Sub Thanks so much, Dave -- Dave Peterson |
#7
Posted to microsoft.public.excel.programming
|
|||
|
|||
Validation List Question
If the macros are in a general module in the same workbook, they should run.
If they are not defined, you should get an error. Otherwise they should run. It is possible you have error handling in the subs and that causes them to appear not to run. Possibly Put message boxes at the top of each sub. -- Regards, Tom Ogilvy "dave!!" wrote in message ... I put a message box in to verify that it's getting past the if statement, and that's working fine, but the macros aren't running. Any thoughts? Thanks, Dave "Tom Ogilvy" wrote in message ... If Target.Address = "$A$4" Then or If Target.Address(0,0) = "A4" Then -- Regards, Tom Ogilvy "dave!!" wrote in message ... I have a data validation list with a number of states in it. Each time I select a new state I want 2 macros to run. The list is in cell A4 of Sheet 1. Here is the code I am using at the worksheet level, can someone tell me what I'm doing wrong? Private Sub Worksheet_Change(ByVal Target As Range) If Target.Address = "A4" Then pp_maj_macro pp_minor_macro End If End Sub Thanks so much, Dave |
#8
Posted to microsoft.public.excel.programming
|
|||
|
|||
Validation List Question
The macros are in a module in the same workbook and there is no error
handling. The macros run if I select them, however they still do not run when I select a new state. I am baffled. "Tom Ogilvy" wrote in message ... If the macros are in a general module in the same workbook, they should run. If they are not defined, you should get an error. Otherwise they should run. It is possible you have error handling in the subs and that causes them to appear not to run. Possibly Put message boxes at the top of each sub. -- Regards, Tom Ogilvy "dave!!" wrote in message ... I put a message box in to verify that it's getting past the if statement, and that's working fine, but the macros aren't running. Any thoughts? Thanks, Dave "Tom Ogilvy" wrote in message ... If Target.Address = "$A$4" Then or If Target.Address(0,0) = "A4" Then -- Regards, Tom Ogilvy "dave!!" wrote in message ... I have a data validation list with a number of states in it. Each time I select a new state I want 2 macros to run. The list is in cell A4 of Sheet 1. Here is the code I am using at the worksheet level, can someone tell me what I'm doing wrong? Private Sub Worksheet_Change(ByVal Target As Range) If Target.Address = "A4" Then pp_maj_macro pp_minor_macro End If End Sub Thanks so much, Dave |
#9
Posted to microsoft.public.excel.programming
|
|||
|
|||
Validation List Question
|
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Validation list question | Excel Discussion (Misc queries) | |||
validation drop down list question | Excel Worksheet Functions | |||
Validation List/Formula Question | Excel Discussion (Misc queries) | |||
Data Validation List Question | Excel Discussion (Misc queries) | |||
Data Validation-List..Question? | Excel Discussion (Misc queries) |