Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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/

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default 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???

  #3   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default 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/

.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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/



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Cleaning Sheets

thanks to every one. It works

--
Message posted from http://www.ExcelForum.com



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
cleaning numbers deb Excel Discussion (Misc queries) 2 January 21st 10 01:56 AM
Cleaning up spread sheets Jan Excel Worksheet Functions 1 September 20th 08 04:01 PM
Help with cleaning up a workbook. Dolphy Excel Discussion (Misc queries) 1 July 25th 07 07:32 AM
Cleaning Up Data [email protected] Excel Discussion (Misc queries) 3 September 20th 06 04:40 PM
cleaning up a field Alex Zaft Excel Programming 2 January 7th 04 05:55 PM


All times are GMT +1. The time now is 02:54 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"