rustyroo
asked on
Add two simple VBA scripts to one in excel macro
I have two simple VBA scripts I am using and they work fine, but I need to run one after the other. Whats the easiest way to do this in an excel Macro.
is it easier to put the two in one.. which would work fine, or else how do you tell a macro to run 2 pieces.
Sure it is a no brainer but figured I would ask those smarter.
Other thing is when I run this macro from a different Tab, it runs on the active tab, not the defined sheet. Sure this is just a error on my part too.
Thanks
Rusty
Sub HideCols()
Dim r As Long, LastRow As Long
LastRow = Sheets("Proposal").UsedRan ge.Rows(Sh eets("Prop osal").Use dRange.Row s.Count).R ow
For r = LastRow To 2 Step -1
If Cells(r, 9) = 0 Then
Rows(r).EntireRow.Hidden = True
End If
Next r
End Sub
Sub UnhideCols()
Dim r As Long, LastRow As Long
LastRow = Sheets("Proposal").UsedRan ge.Rows(Sh eets("Prop osal").Use dRange.Row s.Count).R ow
For r = LastRow To 2 Step -1
If Cells(r, 9) = 1 Then
Rows(r).EntireRow.Hidden = False
End If
Next r
End Sub
is it easier to put the two in one.. which would work fine, or else how do you tell a macro to run 2 pieces.
Sure it is a no brainer but figured I would ask those smarter.
Other thing is when I run this macro from a different Tab, it runs on the active tab, not the defined sheet. Sure this is just a error on my part too.
Thanks
Rusty
Sub HideCols()
Dim r As Long, LastRow As Long
LastRow = Sheets("Proposal").UsedRan
For r = LastRow To 2 Step -1
If Cells(r, 9) = 0 Then
Rows(r).EntireRow.Hidden = True
End If
Next r
End Sub
Sub UnhideCols()
Dim r As Long, LastRow As Long
LastRow = Sheets("Proposal").UsedRan
For r = LastRow To 2 Step -1
If Cells(r, 9) = 1 Then
Rows(r).EntireRow.Hidden = False
End If
Next r
End Sub
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Netminder, I have already put my comments up. If they seem to be wrongly interpreted then I shall end the discussion here. Feel free to delete my comment.
So the accepted answer should have been that and any other response which helps you should have been an assist.