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

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,318
Office Version
  1. 365
Platform
  1. Windows
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
 

headtoadie

Board Regular
Joined
Aug 1, 2003
Messages
219
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
 

Forum statistics

Threads
1,148,218
Messages
5,745,444
Members
423,952
Latest member
EduardoM

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
Top