Macro across books

hammondc

New Member
Joined
Jan 27, 2005
Messages
1
Yaaay, first post! I have a workbook with about 40 sheet in it. I have created a macro to add a certain group of numbers in each of 650 rows . Then it adds the total from each row for a grand total. Is there a way to do this macro across all 35 sheets at one time? If I use ctrl to select all the sheets, The macro will not work correctly.
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
Could you post the macro you currently have? And an explanation of what exactly it is supposed to do.

Generally to go through every worksheet in a workbook you can use something like this:
Code:
Dim wb As Workbook
Dim ws As Worksheet
      
     Set wb = ActiveWorkbook
     
     For Each ws in wb.Worksheets
          ' do something with worksheet ws
     Next ws
 
Upvote 0
this might give you a place to start.

Code:
Option Explicit
Dim x As Integer
Dim sheet As Worksheet
Sub SumSheets()
    For Each sheet In Sheets
        x = x + Application.WorksheetFunction.Sum(sheet.Range("A1:A650"))
    Next
    Sheet1.Cells(1, 2).Value = x
End Sub

HT
 
Upvote 0

Forum statistics

Threads
1,214,646
Messages
6,120,718
Members
448,986
Latest member
andreguerra

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top