ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Validation List Question (https://www.excelbanter.com/excel-programming/338833-validation-list-question.html)

dave!!

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



Dave Peterson

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

Tom Ogilvy

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





dave!!

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




dave!!

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







Tom Ogilvy

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






Tom Ogilvy

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









dave!!

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











Tom Ogilvy

Validation List Question
 
Best I can offer is to take a look at the workbook if you want to email it.



--
Regards,
Tom Ogilvy

"dave!!" wrote in message
...
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














All times are GMT +1. The time now is 10:23 AM.

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