1

I have a Macro however it doesnt seem to be working. I have a workbook which has multipul worksheets. I basically want to copy cells B1, G1, M94 all to a seperate "Summary" worksheet. Copied Cells to go to A4 B4 and C4 than if there is more A5, B5 and C5 and so on.

The coding i have is below. I have tried to make it so it only did it for one sheet but need it for about 10 sheets all with different names.

Sub SummurizeSheets()
Dim ws As Worksheet

Application.ScreenUpdating = False
Sheets("Summary").Activate

For Each ws In Worksheets
    If ws.Name <> "17B CUNNINGHAM" Then
        ws.Range("B1, G1, M94").Copy
        Worksheets("Summary").Cells(Rows.Count, 3).End(xlUp).Offset(1, 0) _
            .PasteSpecial (xlPasteValues)
    End If
Next ws
End Sub

1 Answer 1

1

The problem you will have is you cannot copy/ paste a range the way you have tried to (multiple sections).This should work:

Sub SummurizeSheets()
Dim ws As Worksheet, wsSummary As Worksheet
Dim c As Range

Application.ScreenUpdating = False
Set wsSummary = Sheets("Summary")
' Set destination cell
Set c = wsSummary.Range("A4")

For Each ws In Worksheets
    If ws.Name <> "17B CUNNINGHAM" And ws.Name <> "Summary" Then
        ws.Range("B1").Copy
        c.PasteSpecial (xlPasteValues)
        ws.Range("G1").Copy
        c.Offset(0, 1).PasteSpecial (xlPasteValues)
        ws.Range("M94").Copy
        c.Offset(0, 2).PasteSpecial (xlPasteValues)
        ' Move destination cell one row down
        Set c = c.Offset(1, 0)
    End If

Next ws

Application.ScreenUpdating = True
End Sub

I have used a destination cell to place the paste which you can then offset for the next row so you can use this for multiple sheets. Also excluded the Summary sheet from the For Each and reset the ScreenUpdating

Sign up to request clarification or add additional context in comments.

1 Comment

This worked perfect. Your a champion Thank you so much

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.