Excel Novice 1
New Member
- Joined
- Jan 2, 2024
- Messages
- 7
- Office Version
- 365
- 2010
- Platform
- Windows
Hi - Have never written a Macro before and am lost after reading several posts. I have 2 lists on separate tabs that are both dynamic in length. I want to copy them into a new tab and stack them.
For example - Go to 'Source Sheet 1', Copy range in Cell D6 to dynamic end, Paste in Cell D2 of 'Output Sheet'. Then go to 'Source Sheet 2', copy range in Cell D6 to dynamic end and paste after the end of the first copied range on 'Output Sheet'
I am currently using a vstack formula but want to migrate to VBA. Thanks for the help.
Been working with the following:
For example - Go to 'Source Sheet 1', Copy range in Cell D6 to dynamic end, Paste in Cell D2 of 'Output Sheet'. Then go to 'Source Sheet 2', copy range in Cell D6 to dynamic end and paste after the end of the first copied range on 'Output Sheet'
I am currently using a vstack formula but want to migrate to VBA. Thanks for the help.
Been working with the following:
VBA Code:
Sub copyStuff()
Dim wsIn As Worksheet
Set wsIn = Application.Worksheets("Source Sheet 1")
Dim endRow As Long
wsIn.Activate
endRow = wsIn.Cells(wsIn.Rows.Count, "A").End(xlUp).Row
Dim r As Range
Dim wsOut As Worksheet
Set wsOut = Application.Worksheets("Output Sheet")
' column d to column d
Set r = wsIn.Range(Cells(2, 4), Cells(endRow, 4))
r.Copy
wsOut.Range("D1").PasteSpecial xlPasteAll
End Sub