Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Running Code on Each Sheet in an Excel Workbook

The following code will run on the selected worksheet. Is there a way
to make this run on all worksheets in a workbook? The file this is to
run on contains 52 worksheets in 1 workbook.

Thanx!!


Sub clear9s()
Dim counter
counter = 0


If ActiveCell.Value = "" Then Exit Sub


Do Until ActiveCell.Value = ""
If ActiveCell.Value = "-9999" Then
ActiveCell.Value = "not available"
With Selection.Font
.Size = 6
End With
End If
ActiveCell.Offset(1, 0).Select
counter = counter + 1

Loop
ActiveCell.Offset(-counter, 1).Select

clear9s

End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Running Code on Each Sheet in an Excel Workbook

try using the

"ActiveWorkbook.Worksheets"

command to run the macro for all sheets

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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Running Code on Each Sheet in an Excel Workbook

Sub clear9s()
Dim counter
counter = 0
for each sh in Worksheets
sh.Activate
set rng = ActiveCell
Do Until ActiveCell.Value = ""
If ActiveCell.Value = "-9999" Then
ActiveCell.Value = "not available"
With Selection.Font
.Size = 6
End With
End If
ActiveCell.Offset(1, 0).Select
counter = counter + 1

Loop
rng.select
Next
End Sub

--
Regards,
Tom Ogilvy

"bearie" wrote in message
om...
The following code will run on the selected worksheet. Is there a way
to make this run on all worksheets in a workbook? The file this is to
run on contains 52 worksheets in 1 workbook.

Thanx!!


Sub clear9s()
Dim counter
counter = 0


If ActiveCell.Value = "" Then Exit Sub


Do Until ActiveCell.Value = ""
If ActiveCell.Value = "-9999" Then
ActiveCell.Value = "not available"
With Selection.Font
.Size = 6
End With
End If
ActiveCell.Offset(1, 0).Select
counter = counter + 1

Loop
ActiveCell.Offset(-counter, 1).Select

clear9s

End Sub



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
Workbook sheet code delay Colin Hayes Excel Discussion (Misc queries) 4 June 10th 07 12:02 AM
Help...Code to copy sheet from closed workbook [email protected] Excel Discussion (Misc queries) 1 March 28th 07 08:52 PM
Help:Running a macro in one excel workbook from another workbook R Kapoor Setting up and Configuration of Excel 3 January 13th 06 05:11 AM
running code mark New Users to Excel 3 March 14th 05 09:14 AM
VB code needed for running newer excel version macros in older excel versions Tom Excel Programming 6 October 16th 03 03:11 AM


All times are GMT +1. The time now is 09:44 PM.

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"