VBA looping through workbook to copy a range and combine

StillUnderstanding

Board Regular
Joined
Jan 30, 2021
Messages
80
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
Hi Everyone,

I wonder if you can help me with the VBA below, I want it to loop through the workbook (Excluding the sheets mentioned) then delete 2 columns (e and F) from what is returned.

My issue is that it's only doing the last sheet.

Would someone be able to help me with this please?


VBA Code:
Sub Availability()
Dim ws As Worksheet

Application.ScreenUpdating = False
Sheets("Summary").Activate
Range("A2:g1000").Select
  
    Application.CutCopyMode = False
    Selection.ClearFormats
    Selection.Clear
For Each ws In Worksheets
If ws.Name <> "Summary" And ws.Name <> "Lookup" And ws.Name <> "Index" Then

ws.Range("b2:g3").Copy
Worksheets("Summary").Cells(Rows.Count, 1).End(xlUp).Offset(1, 1).PasteSpecial (xlPasteValues)
  ws.Range("b2:g3").Copy
Worksheets("Summary").Cells(Rows.Count, 1).End(xlUp).Offset(1, 1).PasteSpecial (xlPasteFormats)



 
End If
Next ws


Sheets("Summary").Activate
Range("e2:f1000").Select
Selection.Delete

End Sub
 
Last edited by a moderator:

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
How about
VBA Code:
   If Ws.Name <> "Summary" And Ws.Name <> "Lookup" And Ws.Name <> "Index" Then
      Ws.Range("b2:g3").Copy
      With Worksheets("Summary").Cells(Rows.Count, 2).End(xlUp).Offset(1)
         .PasteSpecial xlPasteValues
         .PasteSpecial xlPasteFormats
      End With
   End If
 
Upvote 0
Solution

Forum statistics

Threads
1,214,951
Messages
6,122,442
Members
449,083
Latest member
Ava19

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