Macro to copy all worksheet data to a summary worksheet on the same file

joycesolomon

New Member
Joined
Aug 2, 2011
Messages
48
hi

I need some help.
I have a excel file that has many sheets. eg sheet1 - sheet100
I also have three others called sheetA, sheetB and sheetC

I need a macro to extract data from sheet1-sheet100 to be placed in a summary sheet...can someone please help.
I been searching and trying some codes but nothing seems to work for me.
Thanks
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
Maybe this example code will help to get you started. It copies cells A1:C6 (i.e. 6 rows) on Sheet1 to Sheet100 to the Summary sheet starting at A1 on the Summary sheet.
Code:
Sub Copy_Cells_To_Summary_Sheet()

    Dim i As Integer
    Dim rowOffset As Long
    
    rowOffset = 0
    For i = 1 To 100
        Sheets("Sheet" & i).Range("A1:C6").Copy Sheets("Summary").Range("A1").Offset(rowOffset, 0)
        rowOffset = rowOffset + 6
    Next
    
End Sub
If you need further help, please state exactly which cells on Sheet1 to Sheet100 should be copied and to where on the Summary sheet.
 
Upvote 0
hi,

i copied your code to a button click and tried running it, it gives out error:

Run time error 9
Subscript out of range

Please help
 
Upvote 0
i managed to get the code running.
But how do I only do for sheet named 1 through 100
I got other sheets like SheetA, SheetB that it is also doing the copy over
 
Upvote 0
But how do I only do for sheet named 1 through 100
I got other sheets like SheetA, SheetB that it is also doing the copy over
The code should only copy cells from sheets named Sheet1, Sheet2, Sheet3, ... Sheet100 (sheet names are case-insensitive so it should also work if they are named sheet1, sheet2, etc.) and ignore all other sheets, for example those named SheetA and SheetB. What are the exact names of your sheets?
 
Upvote 0

Forum statistics

Threads
1,224,587
Messages
6,179,740
Members
452,940
Latest member
Lawrenceiow

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