LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Need Macro to run on all Worksheets at same time

I have a macro below that runs perfectly, but I would like it to run
on all worksheets and not just the active worksheet. The format on
each worksheet is identical, only the data differs. Could someone
help me add the extra code needed for the code to run on all
worksheets at the same time?

Thanks.

Sub SubTotal_All_Worksheets()

Dim intI As Integer
Dim intJ As Integer
Dim intK As Integer
Dim strA As String
Dim strB As String
Dim strFormula As String
Dim CDelta As String
Dim RStart As String
Dim CSum As String

CSum = InputBox("For which column do you wish to create sub-
totals?", "Sub-Total")
CDelta = InputBox("Create sums for each change in what column?",
"Column")
RStart = InputBox("What is the first row of data in that column?",
"Row")

intJ = 0
intK = 0
Range(CDelta & RStart).Select
For intI = 1 To 20000
strA = Range(CDelta & intI + RStart - 1 + intJ)
strB = Range(CDelta & intI + RStart + intJ)
If strA = strB Then
intK = intK + 1
Else:
Range(CDelta & intI + 2 + intJ).Select
Selection.EntireRow.Insert
strFormula = "=sum(" & CSum & (intI + RStart - 1 + intJ) & ":"
& CSum & (intI + RStart - 1 + intJ - intK) & ")"
Range(CSum & intI + RStart + intJ) = strFormula
Range(CSum & intI + RStart + intJ).Select
Selection.Font.Bold = True
intJ = intJ + 1
intK = 0
End If
Next intI

End Sub

 
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
Macro / function text time to 24hr excel time passed midnight fortotaling hr's Russmaz Excel Worksheet Functions 2 March 6th 09 04:58 AM
Scrolling all worksheets at the same time Tim Excel Discussion (Misc queries) 1 November 13th 07 05:01 PM
VBA / Macro for creating new worksheets and new columns from existing worksheets webby2006 Excel Programming 3 July 25th 06 03:38 PM
time and auto macro run by setting time ddiicc Excel Programming 1 September 29th 05 05:32 AM
Help with Macro to Convert Date/Time to Time Only Bill[_26_] Excel Programming 5 August 25th 04 01:50 PM


All times are GMT +1. The time now is 11:31 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"