I am working on code that is essentially going through each sheet through a Workbook and copies all the content in it to paste in in the final Sheet in the Workbook. I currently just have everything paste into Sheet3 as a test, but the issue is it will only copy the content of whichever Sheet I have open when I run the Macro into Sheet3. It will paste the same content from the single Sheet into Sheet3 as many times as I have Sheets, instead of copying the content of each sheet. My current code is this:
Sub Copy_Paste()
'
' Copy_Paste Macro
'
' Keyboard Shortcut: Ctrl+w
'
Dim Current As Worksheet
' Loop through all of the worksheets in the active workbook.
For Each Current In ThisWorkbook.Worksheets
Range("A2", Range("k1048576").End(xlUp)).Select
Selection.Copy
Sheets("Sheet3").Select
Range("A1048576").End(xlUp).Offset(1).Select
ActiveSheet.Paste
MsgBox Current.Name
Next Current
End Sub
I tried returning it to Current each time, like having the first line in the loop be Current.Range("A2", Range("k1048576").End(xlUp)).Select or making the first line Sheets(Current).Select but each would only give errors when I tried to run the code.
Current.Range("A2", Current.Range("K1048576).End(xlUp))Selecton a sheet that isn't active, but you shouldn't be selecting anything here anyways.