Help - !VERY URGENT! - Macros that should activate another

kislicins

New Member
Joined
Jul 23, 2007
Messages
22
Hi. I know I have posted this already in another topic but it is very urgent as I need to hand my work in by the end of today.

I need to write a macros that will activate another macros whenever the cell "I4" is modified. So far it is not working the way it suppose to. Maybe anyone can spot a mistake? Here are both Macros that I have:

Code:
Private Sub Worksheet_Change(ByVal Target As Range) 
Application.EnableEvents = False 
If Not Intersect(Target, [I4]) Is Nothing Then 
Call Macro2 
End If 
Application.EnableEvents = True 
End Sub

and

Code:
Sub Macro2() 
Rows("1:150").Select 
Selection.EntireRow.Hidden = False 
'Ad Cash' 
If Range("$A$13") = "" Then 
Range("$A$13").EntireRow.Hidden = True 
Range("$A$14").EntireRow.Hidden = True 
Else 
Range("$A$13").EntireRow.Hidden = False 
Range("$A$14").EntireRow.Hidden = False 
End If 
'Pension Scheme' 
If Range("$A$17") = "" Then 
Range("$A$17").EntireRow.Hidden = True 
Range("$A$18").EntireRow.Hidden = True 
Else 
Range("$A$17").EntireRow.Hidden = False 
Range("$A$18").EntireRow.Hidden = False 
End If 
'Car' 
If Range("$A$21") = "" Then 
Range("$A$21").EntireRow.Hidden = True 
Range("$A$22").EntireRow.Hidden = True 
Else 
Range("$A$21").EntireRow.Hidden = False 
Range("$A$22").EntireRow.Hidden = False 
End If 
'General Benefits' 
If Range("$B$47") = "" Then 
Range("$B$47").EntireRow.Hidden = True 
Else 
Range("$B$47").EntireRow.Hidden = False 
End If 
If Range("$B$48") = "" Then 
Range("$B$48").EntireRow.Hidden = True 
Else 
Range("$B$48").EntireRow.Hidden = False 
End If 
If Range("$B$49") = "" Then 
Range("$B$49").EntireRow.Hidden = True 
Else 
Range("$B$49").EntireRow.Hidden = False 
End If 
If Range("$B$50") = "" Then 
Range("$B$50").EntireRow.Hidden = True 
Else 
Range("$B$50").EntireRow.Hidden = False 
End If 
If Range("$B$59") = "" Then 
Range("$B$59").EntireRow.Hidden = True 
Else 
Range("$B$59").EntireRow.Hidden = False 
End If 
If Range("$B$61") = "" Then 
Range("$B$61").EntireRow.Hidden = True 
Else 
Range("$B$61").EntireRow.Hidden = False 
End If 
'Additional Payment' 
If Range("$A$78") = "" Then 
Range("$A$78").EntireRow.Hidden = True 
Else 
Range("$A$78").EntireRow.Hidden = False 
End If 
If Range("$A$78") = "" Then 
Range("$A$79").EntireRow.Hidden = True 
Else 
Range("$A$79").EntireRow.Hidden = False 
End If 
If Range("$B$80") = "" Then 
Range("$B$80").EntireRow.Hidden = True 
Else 
Range("$B$80").EntireRow.Hidden = False 
End If 
If Range("$B$81") = "" Then 
Range("$B$81").EntireRow.Hidden = True 
Else 
Range("$B$81").EntireRow.Hidden = False 
End If 
If Range("$B$82") = "" Then 
Range("$B$82").EntireRow.Hidden = True 
Else 
Range("$B$82").EntireRow.Hidden = False 
End If 
If Range("$B$83") = "" Then 
Range("$B$83").EntireRow.Hidden = True 
Else 
Range("$B$83").EntireRow.Hidden = False 
End If 
If Range("$B$84") = "" Then 
Range("$B$84").EntireRow.Hidden = True 
Else 
Range("$B$84").EntireRow.Hidden = False 
End If 
If Range("$B$85") = "" Then 
Range("$B$85").EntireRow.Hidden = True 
Else 
Range("$B$85").EntireRow.Hidden = False 
End If 
If Range("$B$86") = "" Then 
Range("$B$86").EntireRow.Hidden = True 
Else 
Range("$B$86").EntireRow.Hidden = False 
End If 
If Range("$B$87") = "" Then 
Range("$B$87").EntireRow.Hidden = True 
Else 
Range("$B$87").EntireRow.Hidden = False 
End If 
If Range("$B$88") = "" Then 
Range("$B$88").EntireRow.Hidden = True 
Else 
Range("$B$88").EntireRow.Hidden = False 
End If 
If Range("$A$90") = "" Then 
Range("$A$89").EntireRow.Hidden = True 
Else 
Range("$A$89").EntireRow.Hidden = False 
End If 
'Holiday' 
If Range("$A$90") = "" Then 
Range("$A$90").EntireRow.Hidden = True 
Range("$B$91").EntireRow.Hidden = True 
Else 
Range("$A$90").EntireRow.Hidden = False 
Range("$B$91").EntireRow.Hidden = False 
End If 
If Range("$B$92") = "" Then 
Range("$B$92").EntireRow.Hidden = True 
Else 
Range("$B$92").EntireRow.Hidden = False 
End If 
If Range("$B$92") = "" Then 
Range("$B$93").EntireRow.Hidden = True 
Else 
Range("$B$93").EntireRow.Hidden = False 
End If 
If Range("$B$92") = "" Then 
Range("$B$94").EntireRow.Hidden = True 
Else 
Range("$B$94").EntireRow.Hidden = False 
End If 
If Range("$A$96") = "" Then 
Range("$B$95").EntireRow.Hidden = True 
Else 
Range("$B$95").EntireRow.Hidden = False 
End If 
'Pension Scheme' 
If Range("$A$96") = "" Then 
Range("$A$96").EntireRow.Hidden = True 
Range("$B$97").EntireRow.Hidden = True 
Else 
Range("$A$96").EntireRow.Hidden = False 
Range("$B$97").EntireRow.Hidden = False 
End If 
If Range("$B$98") = "" Then 
Range("$B$98").EntireRow.Hidden = True 
Else 
Range("$B$98").EntireRow.Hidden = False 
End If 
If Range("$A$100") = "" Then 
Range("$B$99").EntireRow.Hidden = True 
Else 
Range("$B$99").EntireRow.Hidden = False 
End If 

'Tax Efficient Share Plan' 
If Range("$A$100") = "" Then 
Range("$A$100").EntireRow.Hidden = True 
Range("$B$101").EntireRow.Hidden = True 
Else 
Range("$A$100").EntireRow.Hidden = False 
Range("$B$101").EntireRow.Hidden = False 
End If 
If Range("$B$102") = "" Then 
Range("$B$102").EntireRow.Hidden = True 
Else 
Range("$B$102").EntireRow.Hidden = False 
End If 
If Range("$B$103") = "" Then 
Range("$B$103").EntireRow.Hidden = True 
Else 
Range("$B$103").EntireRow.Hidden = False 
End If 
If Range("$A$105") = "" Then 
Range("$B$104").EntireRow.Hidden = True 
Else 
Range("$B$104").EntireRow.Hidden = False 
End If 
'Car' 
If Range("$A$118") = "" Then 
Range("$A$118").EntireRow.Hidden = True 
Range("$B$119").EntireRow.Hidden = True 
Else 
Range("$A$118").EntireRow.Hidden = False 
Range("$B$119").EntireRow.Hidden = False 
End If 
If Range("$A$120") = "" Then 
Range("$B$120").EntireRow.Hidden = True 
Else 
Range("$B$120").EntireRow.Hidden = False 
End If 
If Range("$A$121") = "" Then 
Range("$B$121").EntireRow.Hidden = True 
Else 
Range("$B$121").EntireRow.Hidden = False 
End If 
If Range("$A$122") = "" Then 
Range("$B$122").EntireRow.Hidden = True 
Else 
Range("$B$122").EntireRow.Hidden = False 
End If 
If Range("$A$123") = "" Then 
Range("$B$123").EntireRow.Hidden = True 
Else 
Range("$B$123").EntireRow.Hidden = False 
End If 

Application.ScreenUpdating = True 

End Sub

Honestly to say I am rubbish with VB and I have started using it only yesterday but it is essencial for me to get this one right. Any help will be very appreciated! It looks like Macro2 is not kicking in but works all right if activated manually. But whenever I change "I4" nothing happens.

P.S. just in case - I have no idea if my macros are written in the right place. First one is under VBA Project (Your Total Reward) > Microsoft Excel Objects> HideRows (Total Reward Statement) and the second one is under Modules > Module 1
 
kislicins

The original problem is probably what I suggested - events were turned off.

You could have used the code I posted to turn them back on, but opening and closing the workbook would resolve the issue too.:)
 
Upvote 0

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
Yes, I am sure that was the case. In the end I just wrote a macros that was copying the data from one cell to another, calling macro2 after it (with hiderows), printing and then repeating itself for 1500 times. Everything works and I can go home happy. Thanks everyone who helped!
 
Upvote 0

Forum statistics

Threads
1,224,802
Messages
6,181,048
Members
453,014
Latest member
Chris258

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top