mdonovan890
New Member
- Joined
- Dec 22, 2016
- Messages
- 24
i'm New VBA and Marcos and am hoping someone can help. I have workbook with 50 plus sheets and I am trying to create a Macro that will copy the same range of cells on all sheets that have "Box" in the in the name and copy it to a Master Sheet in the same workbook with the originating sheet name shown in column J.
The issue is that this code copies all sheets within the workbook, the source column does not populate correctly and none of the formatting is copied. I am using Excel 2016 any help would be greatly appreciated.
After a lot of searching, this is what I have so far:
Public Sub m()
Dim lRow As Long
Dim sh As Worksheet
Dim shArc As Worksheet
Set shArc = ThisWorkbook.Worksheets("Archive")
For Each sh In ThisWorkbook.Worksheets
Select Case sh.Name
Case Is <> "Archive"
lRow = shArc.Range("A" & Rows.Count).End(xlUp).Row + 1
sh.Range("A2:I110").Copy
shArc.Range("A" & lRow).PasteSpecial
DestSh.Cells(Last + 1, "J").Resize(CopyRng.Rows.Count).Value = sh.Name
End Select
Next
Application.CutCopyMode = False
Set shArc = Nothing
Set sh = Nothing
The issue is that this code copies all sheets within the workbook, the source column does not populate correctly and none of the formatting is copied. I am using Excel 2016 any help would be greatly appreciated.
After a lot of searching, this is what I have so far:
Public Sub m()
Dim lRow As Long
Dim sh As Worksheet
Dim shArc As Worksheet
Set shArc = ThisWorkbook.Worksheets("Archive")
For Each sh In ThisWorkbook.Worksheets
Select Case sh.Name
Case Is <> "Archive"
lRow = shArc.Range("A" & Rows.Count).End(xlUp).Row + 1
sh.Range("A2:I110").Copy
shArc.Range("A" & lRow).PasteSpecial
DestSh.Cells(Last + 1, "J").Resize(CopyRng.Rows.Count).Value = sh.Name
End Select
Next
Application.CutCopyMode = False
Set shArc = Nothing
Set sh = Nothing
Last edited: