#1   Report Post  
Posted to microsoft.public.excel.misc
daidipya
 
Posts: n/a
Default two macros

I have the following code copy pasted in the "input-assumptions" with
this the macro is running quite well.

Sub HideRows1()
Dim Rng As Range
Set Rng = Sheets("input-assumptions").Range("E88")
If Rng.Value = "Yes" Then
Rows("89:89").EntireRow.Hidden = False
Range("E89").Select
ElseIf Rng.Value = "No" Then
Rows("89:89").EntireRow.Hidden = True
Range("E88").Select
End If
End Sub

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Row < 88 Then Exit Sub
If Target.Column < 5 Then Exit Sub
HideRows1
End Sub

i have also another code as follows, which has been copy pasted belwo
the above code

Sub HideRows2()
Dim Rng As Range
Set Rng = Sheets("input-assumptions").Range("E89")
If Rng.Value = "Yes" Then
Rows("90:121").EntireRow.Hidden = False
Range("E89").Select
ElseIf Rng.Value = "No" Then
Rows("90:121").EntireRow.Hidden = True
Range("E89").Select
End If
End Sub

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Row < 89 Then Exit Sub
If Target.Column < 5 Then Exit Sub
HideRows2
End Sub

However if i choose "YES" or "NO" in any of the E88 and E89 cells i get
a Complie error and ambigious name detetected: worksheet change

how to run both the macros without having any error

please help me

  #2   Report Post  
Posted to microsoft.public.excel.misc
Trevor Shuttleworth
 
Posts: n/a
Default two macros

You can only have one Worksheet_Change event:

Try:

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Row = 88 And Target.Column = 5 Then
HideRows1
End If
If Target.Row = 89 And Target.Column = 5 Then
HideRows2
End If
End Sub

Regards

Trevor


"daidipya" wrote in message
oups.com...
I have the following code copy pasted in the "input-assumptions" with
this the macro is running quite well.

Sub HideRows1()
Dim Rng As Range
Set Rng = Sheets("input-assumptions").Range("E88")
If Rng.Value = "Yes" Then
Rows("89:89").EntireRow.Hidden = False
Range("E89").Select
ElseIf Rng.Value = "No" Then
Rows("89:89").EntireRow.Hidden = True
Range("E88").Select
End If
End Sub

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Row < 88 Then Exit Sub
If Target.Column < 5 Then Exit Sub
HideRows1
End Sub

i have also another code as follows, which has been copy pasted belwo
the above code

Sub HideRows2()
Dim Rng As Range
Set Rng = Sheets("input-assumptions").Range("E89")
If Rng.Value = "Yes" Then
Rows("90:121").EntireRow.Hidden = False
Range("E89").Select
ElseIf Rng.Value = "No" Then
Rows("90:121").EntireRow.Hidden = True
Range("E89").Select
End If
End Sub

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Row < 89 Then Exit Sub
If Target.Column < 5 Then Exit Sub
HideRows2
End Sub

However if i choose "YES" or "NO" in any of the E88 and E89 cells i get
a Complie error and ambigious name detetected: worksheet change

how to run both the macros without having any error

please help me



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
Hide Macro's in Toolbar / Macro's list sparx Excel Discussion (Misc queries) 2 May 6th 06 08:53 PM
how do I run excel 4.0 macros on excel 2000 RodolfoDallas Excel Discussion (Misc queries) 1 March 12th 06 03:14 AM
Excel crashes while opening excel file imbeddied with macros ct2147 Excel Discussion (Misc queries) 0 December 30th 05 09:05 PM
Enabling macros Peter M Excel Discussion (Misc queries) 3 February 7th 05 10:57 PM
Transferring toolbars and macros to other computers Darrell Excel Discussion (Misc queries) 1 January 19th 05 12:21 AM


All times are GMT +1. The time now is 05:57 PM.

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"