Cycling through multiple sheets with the same range and copying all to a new workbook

bigbeat85

New Member
Joined
May 24, 2017
Messages
23
Hi all,

I have imported a range of pdfs into excel and populates the same cells in every worksheet.
Each worksheet names starts from 'Page001' and will continue to Page055. The page numbers are odd numbers. 'Page001' 'Page003' 'Page005' and so on.

On each sheet the range copied is
" Sheets("Page019").Select
Selection.AutoFilter
Range("A9:B16").Select
Selection.Copy"
Application.WindowState = xlNormal
Workbooks.Open Filename:= _ "External sheet to copy data"
ActiveWindow.Close
Workbooks.Add

Here I wanted to add to a specific line as that is where the data entry finishes.
" Range("A552").Select"
I'm also transposing it with the below
" Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=True"

I can get it to work for one sheet but unsure how to cycle through multiple sheets to copy and paste the new data into the new sheet "External sheet to copy data"

It is something that should be easy. But brain fog is hitting me
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
Your code is a little unclear (e.g. you apply AutoFilter but then don't seem to use it for anything) and it would have helped to see all of your code, not just part of it. However, please try the following on a copy of your workbook. The code sits in the workbook with all the sheets to be copied to a new workbook.

VBA Code:
Option Explicit
Sub bigbeat85()
    Dim ws As Worksheet, wsDest As Worksheet
    Workbooks.Add
    Set wsDest = ActiveSheet
    For Each ws In ThisWorkbook.Worksheets
        ws.Range("A9:B16").Copy wsDest.Cells(Rows.Count, 1).End(xlUp).Offset(1)
    Next ws
End Sub
 
Upvote 0
Thank you Kevin! That worked really well! It is copying all the required data.

It should be clearer. My error.

With the range that I am copying from each sheet I am then trying to transpose as well. That is the tricky bit I am facing
 
Upvote 0
Understood. See if this gives you what you want:
VBA Code:
Option Explicit
Sub bigbeat85()
    Dim ws As Worksheet, wsDest As Worksheet
    Workbooks.Add
    Set wsDest = ActiveSheet
    For Each ws In ThisWorkbook.Worksheets
        ws.Range("A9:B16").Copy
        wsDest.Cells(Rows.Count, 1).End(xlUp).Offset(1).PasteSpecial Transpose:=True
        Application.CutCopyMode = False
    Next ws
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,902
Messages
6,175,278
Members
452,629
Latest member
SahilPolekar

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