Link to home
Start Free TrialLog in
Avatar of rustyroo
rustyrooFlag for Australia

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").UsedRange.Rows(Sheets("Proposal").UsedRange.Rows.Count).Row
    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").UsedRange.Rows(Sheets("Proposal").UsedRange.Rows.Count).Row
    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
Avatar of Saqib Husain
Saqib Husain
Flag of Pakistan image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I thought the question was
how do you tell a macro to run 2 pieces
because you knew how to
put the two in one.. which would work fine

So the accepted answer should have been that and any other response which helps you should have been an assist.
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.