Link to home
Start Free TrialLog in
Avatar of Bob Barnes
Bob BarnesFlag for United Kingdom of Great Britain and Northern Ireland

asked on

How can this Excel macro be more efficient and more versatile?

I have attached abridged detals of an Excel macro, which each week has to be renamed to work with the current week and enlarged to include an additional line of activity. Although this sort of works, it's cumbersome and I would like it to be more efficient and versatile. I have included details of Week 03, Week 04 and Week 05 so you can see the week by week progression as the macro grows; by the end of the year I will have 52 separate macros. Just one macro to do the whole job would be great. Thanks for any help available.
Bob
Avatar of regmigrant
regmigrant
Flag of United Kingdom of Great Britain and Northern Ireland image

attachment missing?
Avatar of Bob Barnes

ASKER

Here's a slightly more concise version of your first subroutine; you could easily adapt this code to your other two:
Sub Prepare_Week_03()
    Dim r As Integer
    Selection.Copy
    Windows("Week_03.xlsx").Activate
    Range("A2").Select
    Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats
    For r = 5 To 7
        If Cells(r, 2) <> 0 Then GoTo Fin
        Cells(r, 2).EntireRow.Hidden = True
    Next r
Fin:
    Range("A2").Select
    ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
End Sub

Open in new window


Regards,
-Glenn
ASKER CERTIFIED SOLUTION
Avatar of Glenn Ray
Glenn Ray
Flag of United States of America 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