Copying a workbook sheet to the bottom of another workbook sheet

Mr_Phil

Board Regular
Joined
May 28, 2018
Messages
147
Office Version
  1. 365
Hi Everyone. I pull multiple reports from the same source and they are all built (same number of columns & same headers) identically. Only the data is different. Obviously I can copy them, go to the very bottom of the first workbook data, and paste in the first row. That was fine where there were only five reports. Now there are sixteen and that might be going up. So I was wondering if there is a short macro I can put in my macro workbook that will automate that? I tried the macro recorder and it worked except that instead of the first blank row on the main sheet it went to the cell reference where I pasted it while recording it. That could be data lost but I can't quite figure out how to change the cell reference to the first blank row. I appreciate anyone looking and offering advice. If this is already asked/answered I'd be grateful for a link so I can learn a bit. Thanks again.

Code:
Sub Macro3()
'
' Macro3 Macro
'

'
    Range("A2").Select
    Range(Selection, Selection.End(xlToRight)).Select
    Range(Selection, Selection.End(xlDown)).Select
    Selection.Copy
    Windows("OFFICE DATA TTWO.xlsx").Activate
'this is where I would like to tell it to select the first column A cell so that it will paste the data there.
    Range(Selection, Selection.End(xlDown)).Select
    ActiveWindow.SmallScroll Down:=6
    Range("A157").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Application.CutCopyMode = False
    ActiveWorkbook.Save
    Windows("OFFICE DATA TTT.xlsx").Activate
    ActiveWindow.Close
End Sub

Thank you again for looking and have a wonderful weekend
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
Replace this:
VBA Code:
    Range(Selection, Selection.End(xlDown)).Select
    ActiveWindow.SmallScroll Down:=6
    Range("A157").Select
with this:
VBA Code:
    Cells(Rows.Count, "A").End(xlUp).Offset(1,0).Select

This will select the cell after the last populated row in column A.
 
Upvote 0
Solution
Replace this:
VBA Code:
    Range(Selection, Selection.End(xlDown)).Select
    ActiveWindow.SmallScroll Down:=6
    Range("A157").Select
with this:
VBA Code:
    Cells(Rows.Count, "A").End(xlUp).Offset(1,0).Select

This will select the cell after the last populated row in column A.

That did the trick. Thank you very much.
 
Upvote 0
You are welcome.
Glad I was able to help.
 
Upvote 0

Forum statistics

Threads
1,223,767
Messages
6,174,395
Members
452,561
Latest member
amir5104

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top