Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 109
Default 2 validation macros

Hi,
I have two different cells with different validation results. I would a
macro to run for each of them depending on my scenario. It works for cell
A14, but does not work for A16. Why? What is wrong with this picture?

Private Sub Worksheet_Change(ByVal Target As Range)
Application.ScreenUpdating = False
If Target.Address = "$A$14" Then
Application.EnableEvents = False
Call selectedmacro_click
Application.EnableEvents = True
End If
Application.ScreenUpdating = True

End Sub
Private Sub selectedmacro_click()
Range("A:IV").EntireColumn.Hidden = False

For Each c In Range("B1:IV1")
If c < 1 Then Columns(c.Column).Hidden = True
Next c

Range("A10").Select
End Sub
Private Sub Target()
Range("A:IV").EntireColumn.Hidden = False

For Each c In Range("B1:IV1")
If c < 1 Then Columns(c.Column).Hidden = True
Next c

Range("A10").Select
End Sub

Private Sub Worksheet1_Change(ByVal Period As Range)
Application.ScreenUpdating = False
If Period.Address = "$A$16" Then
Application.EnableEvents = False
Call selectedmacro1_click
Application.EnableEvents = True
End If
Application.ScreenUpdating = True

End Sub
Private Sub selectedmacro1_click()
Range("A:IV").EntireColumn.Hidden = False

For Each c In Range("B5:IV5")
If c < 1 Then Columns(c.Column).Hidden = True
Next c

Range("A10").Select
End Sub
Private Sub Period()
Range("A:IV").EntireColumn.Hidden = False

For Each c In Range("B5:IV5")
If c < 1 Then Columns(c.Column).Hidden = True
Next c

Range("A10").Select
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,533
Default 2 validation macros

Hi

As you can only have one worksheet_change macro, you have to do it like
this:

Private Sub Worksheet_Change(ByVal Target As Range)
Application.ScreenUpdating = False
If Target.Address = "$A$14" Then
Application.EnableEvents = False
Call selectedmacro_click
Application.EnableEvents = True
ElseIf Target.Address = "$A$16" Then
Application.EnableEvents = False
Call selectedmacro1_click
Application.EnableEvents = True
End If
Application.ScreenUpdating = True
End Sub

Regards,
Per

"MrRJ" skrev i meddelelsen
...
Hi,
I have two different cells with different validation results. I would a
macro to run for each of them depending on my scenario. It works for cell
A14, but does not work for A16. Why? What is wrong with this picture?

Private Sub Worksheet_Change(ByVal Target As Range)
Application.ScreenUpdating = False
If Target.Address = "$A$14" Then
Application.EnableEvents = False
Call selectedmacro_click
Application.EnableEvents = True
End If
Application.ScreenUpdating = True

End Sub
Private Sub selectedmacro_click()
Range("A:IV").EntireColumn.Hidden = False

For Each c In Range("B1:IV1")
If c < 1 Then Columns(c.Column).Hidden = True
Next c

Range("A10").Select
End Sub
Private Sub Target()
Range("A:IV").EntireColumn.Hidden = False

For Each c In Range("B1:IV1")
If c < 1 Then Columns(c.Column).Hidden = True
Next c

Range("A10").Select
End Sub

Private Sub Worksheet1_Change(ByVal Period As Range)
Application.ScreenUpdating = False
If Period.Address = "$A$16" Then
Application.EnableEvents = False
Call selectedmacro1_click
Application.EnableEvents = True
End If
Application.ScreenUpdating = True

End Sub
Private Sub selectedmacro1_click()
Range("A:IV").EntireColumn.Hidden = False

For Each c In Range("B5:IV5")
If c < 1 Then Columns(c.Column).Hidden = True
Next c

Range("A10").Select
End Sub
Private Sub Period()
Range("A:IV").EntireColumn.Hidden = False

For Each c In Range("B5:IV5")
If c < 1 Then Columns(c.Column).Hidden = True
Next c

Range("A10").Select
End Sub


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,533
Default 2 validation macros

Hi

As you can only have one worksheet_change macro, you have to do it like
this:

Private Sub Worksheet_Change(ByVal Target As Range)
Application.ScreenUpdating = False
If Target.Address = "$A$14" Then
Application.EnableEvents = False
Call selectedmacro_click
Application.EnableEvents = True
ElseIf Target.Address = "$A$16" Then
Application.EnableEvents = False
Call selectedmacro1_click
Application.EnableEvents = True
End If
Application.ScreenUpdating = True
End Sub

Regards,
Per

"MrRJ" skrev i meddelelsen
...
Hi,
I have two different cells with different validation results. I would a
macro to run for each of them depending on my scenario. It works for cell
A14, but does not work for A16. Why? What is wrong with this picture?

Private Sub Worksheet_Change(ByVal Target As Range)
Application.ScreenUpdating = False
If Target.Address = "$A$14" Then
Application.EnableEvents = False
Call selectedmacro_click
Application.EnableEvents = True
End If
Application.ScreenUpdating = True

End Sub
Private Sub selectedmacro_click()
Range("A:IV").EntireColumn.Hidden = False

For Each c In Range("B1:IV1")
If c < 1 Then Columns(c.Column).Hidden = True
Next c

Range("A10").Select
End Sub
Private Sub Target()
Range("A:IV").EntireColumn.Hidden = False

For Each c In Range("B1:IV1")
If c < 1 Then Columns(c.Column).Hidden = True
Next c

Range("A10").Select
End Sub

Private Sub Worksheet1_Change(ByVal Period As Range)
Application.ScreenUpdating = False
If Period.Address = "$A$16" Then
Application.EnableEvents = False
Call selectedmacro1_click
Application.EnableEvents = True
End If
Application.ScreenUpdating = True

End Sub
Private Sub selectedmacro1_click()
Range("A:IV").EntireColumn.Hidden = False

For Each c In Range("B5:IV5")
If c < 1 Then Columns(c.Column).Hidden = True
Next c

Range("A10").Select
End Sub
Private Sub Period()
Range("A:IV").EntireColumn.Hidden = False

For Each c In Range("B5:IV5")
If c < 1 Then Columns(c.Column).Hidden = True
Next c

Range("A10").Select
End Sub


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 109
Default 2 validation macros

That is awesome. It works. Thanks Per

"Per Jessen" wrote:

Hi

As you can only have one worksheet_change macro, you have to do it like
this:

Private Sub Worksheet_Change(ByVal Target As Range)
Application.ScreenUpdating = False
If Target.Address = "$A$14" Then
Application.EnableEvents = False
Call selectedmacro_click
Application.EnableEvents = True
ElseIf Target.Address = "$A$16" Then
Application.EnableEvents = False
Call selectedmacro1_click
Application.EnableEvents = True
End If
Application.ScreenUpdating = True
End Sub

Regards,
Per

"MrRJ" skrev i meddelelsen
...
Hi,
I have two different cells with different validation results. I would a
macro to run for each of them depending on my scenario. It works for cell
A14, but does not work for A16. Why? What is wrong with this picture?

Private Sub Worksheet_Change(ByVal Target As Range)
Application.ScreenUpdating = False
If Target.Address = "$A$14" Then
Application.EnableEvents = False
Call selectedmacro_click
Application.EnableEvents = True
End If
Application.ScreenUpdating = True

End Sub
Private Sub selectedmacro_click()
Range("A:IV").EntireColumn.Hidden = False

For Each c In Range("B1:IV1")
If c < 1 Then Columns(c.Column).Hidden = True
Next c

Range("A10").Select
End Sub
Private Sub Target()
Range("A:IV").EntireColumn.Hidden = False

For Each c In Range("B1:IV1")
If c < 1 Then Columns(c.Column).Hidden = True
Next c

Range("A10").Select
End Sub

Private Sub Worksheet1_Change(ByVal Period As Range)
Application.ScreenUpdating = False
If Period.Address = "$A$16" Then
Application.EnableEvents = False
Call selectedmacro1_click
Application.EnableEvents = True
End If
Application.ScreenUpdating = True

End Sub
Private Sub selectedmacro1_click()
Range("A:IV").EntireColumn.Hidden = False

For Each c In Range("B5:IV5")
If c < 1 Then Columns(c.Column).Hidden = True
Next c

Range("A10").Select
End Sub
Private Sub Period()
Range("A:IV").EntireColumn.Hidden = False

For Each c In Range("B5:IV5")
If c < 1 Then Columns(c.Column).Hidden = True
Next c

Range("A10").Select
End Sub



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 109
Default 2 validation macros

That is awesome. It works. Thanks Per

"Per Jessen" wrote:

Hi

As you can only have one worksheet_change macro, you have to do it like
this:

Private Sub Worksheet_Change(ByVal Target As Range)
Application.ScreenUpdating = False
If Target.Address = "$A$14" Then
Application.EnableEvents = False
Call selectedmacro_click
Application.EnableEvents = True
ElseIf Target.Address = "$A$16" Then
Application.EnableEvents = False
Call selectedmacro1_click
Application.EnableEvents = True
End If
Application.ScreenUpdating = True
End Sub

Regards,
Per

"MrRJ" skrev i meddelelsen
...
Hi,
I have two different cells with different validation results. I would a
macro to run for each of them depending on my scenario. It works for cell
A14, but does not work for A16. Why? What is wrong with this picture?

Private Sub Worksheet_Change(ByVal Target As Range)
Application.ScreenUpdating = False
If Target.Address = "$A$14" Then
Application.EnableEvents = False
Call selectedmacro_click
Application.EnableEvents = True
End If
Application.ScreenUpdating = True

End Sub
Private Sub selectedmacro_click()
Range("A:IV").EntireColumn.Hidden = False

For Each c In Range("B1:IV1")
If c < 1 Then Columns(c.Column).Hidden = True
Next c

Range("A10").Select
End Sub
Private Sub Target()
Range("A:IV").EntireColumn.Hidden = False

For Each c In Range("B1:IV1")
If c < 1 Then Columns(c.Column).Hidden = True
Next c

Range("A10").Select
End Sub

Private Sub Worksheet1_Change(ByVal Period As Range)
Application.ScreenUpdating = False
If Period.Address = "$A$16" Then
Application.EnableEvents = False
Call selectedmacro1_click
Application.EnableEvents = True
End If
Application.ScreenUpdating = True

End Sub
Private Sub selectedmacro1_click()
Range("A:IV").EntireColumn.Hidden = False

For Each c In Range("B5:IV5")
If c < 1 Then Columns(c.Column).Hidden = True
Next c

Range("A10").Select
End Sub
Private Sub Period()
Range("A:IV").EntireColumn.Hidden = False

For Each c In Range("B5:IV5")
If c < 1 Then Columns(c.Column).Hidden = True
Next c

Range("A10").Select
End Sub



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macros & Validation John Calder New Users to Excel 0 June 13th 06 02:48 AM
ID Validation using macros in excel Sridhar Machina Excel Programming 4 September 2nd 05 12:52 PM
Validation/Macros Tom Ogilvy Excel Programming 1 January 15th 04 04:21 PM
Validation/Macros Ron de Bruin Excel Programming 1 January 15th 04 04:19 PM
Validation/Macros Ron de Bruin Excel Programming 0 January 15th 04 04:13 PM


All times are GMT +1. The time now is 08:32 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"