Hi,
I have a project where I need to copy select cell values from 200+ sheets into One sheet (Kind of like a report).
The cell numbers are the same across all worksheets,
I managed to get the copy portion to work but its only running it on one worksheet, for some reason its the last sheet.
Im completely new to VBA so bare with me. Below is what I am running:
I have a project where I need to copy select cell values from 200+ sheets into One sheet (Kind of like a report).
The cell numbers are the same across all worksheets,
I managed to get the copy portion to work but its only running it on one worksheet, for some reason its the last sheet.
Im completely new to VBA so bare with me. Below is what I am running:
Code:
Sub Macro8()
Dim sh As Worksheet
Dim DestSh As Worksheet
Dim LastRow As Long
Dim CopyRng As Range
With Application
.ScreenUpdating = False
.EnableEvents = False
End With
'Delete the sheet "Report" if it exist
Application.DisplayAlerts = False
On Error Resume Next
ActiveWorkbook.Worksheets("Report").Delete
On Error GoTo 0
Application.DisplayAlerts = True
'Add a worksheet with the name "Report"
Set DestSh = ActiveWorkbook.Worksheets.Add
DestSh.Name = "Report"
'loop through all worksheets and copy the data to the DestSh
For Each sh In ThisWorkbook.Worksheets
If sh.Name <> DestSh.Name Then
'selecting the next row in report
'Find the last row with data on the DestSh
LastRow = DestSh.Range("A1").SpecialCells(xlCellTypeLastCell).Rows
'Fill in the range that you want to copy
Set CopyRng = sh.Range("A2:C2, BI2:BK2")
'This example copies values/formats, if you only want to copy the
'values or want to copy everything look at the example below this macro
CopyRng.Copy
With DestSh.Cells(Last + 1, "A")
.PasteSpecial xlPasteValues
.PasteSpecial xlPasteFormats
Application.CutCopyMode = False
End With
End If
Next sh
End Sub
Last edited by a moderator: