I have an excel workbook with many different sheets. Each sheet has a single macro in it wich saves the sheet as a pdf and opens outlook with that pdf as an attachment. I am looking for a function to place on one worksheet that will run each macro without having to manually run each on their respective worksheets.
0
-
For/Each loop. Show us your function, please? – David Zemens Jan 6 '15 at 17:00
0
Say there is a macro in each worksheet called SheetMac. Put the following in a standard module and run it:
Sub MASTER()
For Each sh In Sheets
sh.Activate
Call sh.SheetMac
Next sh
End Sub
-
tried this, getting error: "Run-time error '438': Object doesn't support this property or method" FYI macro name is: RDB_Worksheet_Or_Worksheets_To_PDF_And_Create_Mail – user3723502 Jan 6 '15 at 17:35
-
got it to work with this:
Sub RunAll() Dim SHt As Worksheet For Each SHt In ThisWorkbook.Worksheets SHt.Activate Call RDB_Worksheet_Or_Worksheets_To_PDF_And_Create_Mail Next SHt End Sub
– user3723502 Jan 6 '15 at 17:41