Loop through worksheets and copy contents to summary tab

TaskMaster

Board Regular
Joined
Oct 15, 2020
Messages
55
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Hi all,

I am wondering if you can help me with a query im stuck on. I am wanting to copy the contents of column B in each tab and copy them into column A of my summary tab beneath each other. I have tried doing this myself with little success, hoping you can help me decipher what im doing wrong or suggest a better way. Thank you in advance.

VBA Code:
Sub Summary()

    Dim WS As Worksheet
    
        For Each WS In Worksheets
            Select Case WS.Name
                Case "Summary", "Deal Numbers" 'ignore list
                Case Else
                    
                        WS.Select
                        LR = Sheets(WS).Cells(.Rows.Count, "B").End(xlUp).Row
                        .Range("B2:" & LR).Copy
                        LastRow = Sheets("Summary").Cells(Rows.Count, "A").End(xlUp).Offset(1, 0).Row
                        Sheets("Summary").Range("A:" & LastRow).PasteSpecial Paste:=xlValues
                        DoEvents
        Next WS
    
End Sub
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
Hi TaskMaster,

what about

VBA Code:
Sub Summary_MrE1221187()
  
  Dim WS As Worksheet
  Dim LR As Long
  
  For Each WS In Worksheets
    Select Case WS.Name
      Case "Summary", "Deal Numbers" 'ignore list
      Case Else
        LR = WS.Cells(WS.Rows.Count, "B").End(xlUp).Row
        WS.Range("B2:B" & LR).Copy
        Sheets("Summary").Cells(Rows.Count, "A").End(xlUp).Offset(1, 0).PasteSpecial Paste:=xlValues
    End Select
  Next WS
  
End Sub

Ciao,
Holger
 
Upvote 0
Solution
Hi TaskMaster,

what about

VBA Code:
Sub Summary_MrE1221187()
 
  Dim WS As Worksheet
  Dim LR As Long
 
  For Each WS In Worksheets
    Select Case WS.Name
      Case "Summary", "Deal Numbers" 'ignore list
      Case Else
        LR = WS.Cells(WS.Rows.Count, "B").End(xlUp).Row
        WS.Range("B2:B" & LR).Copy
        Sheets("Summary").Cells(Rows.Count, "A").End(xlUp).Offset(1, 0).PasteSpecial Paste:=xlValues
    End Select
  Next WS
 
End Sub

Ciao,
Holger
Hi Holger,

This is works perfectly. Thank you for your assistance!!

TM
 
Upvote 0
Hi TaskMaster,

thanks for the feedback.

Holger
 
Upvote 0

Forum statistics

Threads
1,213,543
Messages
6,114,240
Members
448,555
Latest member
RobertJones1986

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