Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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/ |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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??? |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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/ . |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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/ |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
cleaning numbers | Excel Discussion (Misc queries) | |||
Cleaning up spread sheets | Excel Worksheet Functions | |||
Help with cleaning up a workbook. | Excel Discussion (Misc queries) | |||
Cleaning Up Data | Excel Discussion (Misc queries) | |||
cleaning up a field | Excel Programming |