![]() |
Cleaning Sheets
Hi:
I have a macro that clears the content of different cells in a worksheet and it works fine. The problem is that our workbooks some times have over 50 worksheets and the macro has to be ran manually 50 times one per sheet. is there a way to run it on all sheets but playing the macro only once??? --- Message posted from http://www.ExcelForum.com/ |
Cleaning Sheets
No, but you can loop through the workbook:
Public Sub ClearContentsAllSheets() Dim wsSheet As Worksheet For Each wsSheet In ThisWorkbook.Worksheets wsSheet.Cells.ClearContents Next wsSheet End Sub In article , halem2 wrote: Hi: I have a macro that clears the content of different cells in a worksheet and it works fine. The problem is that our workbooks some times have over 50 worksheets and the macro has to be ran manually 50 times one per sheet. is there a way to run it on all sheets but playing the macro only once??? |
Cleaning Sheets
hi,
this might work Sub Test() Dim ws As Worksheet For Each ws In ActiveWorkbook.Worksheets On Error Resume Next call YourMacro On Error GoTo 0 Next ws End Sub -----Original Message----- Hi: I have a macro that clears the content of different cells in a worksheet and it works fine. The problem is that our workbooks some times have over 50 worksheets and the macro has to be ran manually 50 times one per sheet. is there a way to run it on all sheets but playing the macro only once??? --- Message posted from http://www.ExcelForum.com/ . |
Cleaning Sheets
Sub Trigger()
for each sh in Activeworkbook.Worksheets sh.Activate myMacro Next End Sub assume your current macro is named MyMacro. Edit the above code to reflect the actual name of your macro. -- Regards, Tom Ogilvy "halem2 " wrote in message ... Hi: I have a macro that clears the content of different cells in a worksheet and it works fine. The problem is that our workbooks some times have over 50 worksheets and the macro has to be ran manually 50 times one per sheet. is there a way to run it on all sheets but playing the macro only once??? --- Message posted from http://www.ExcelForum.com/ |
Cleaning Sheets
|
All times are GMT +1. The time now is 04:53 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com