Macro to append data to the bottom of a column

RachelBrown

New Member
Joined
Jul 6, 2017
Messages
11
I have a macro that adds data to the bottom of a column, it worked the first time but it keeps pasting in different spots in my worksheet. Can someone spot what is wrong?


Code:
Dim lastRow As String
Range("D3").Select
    Range(Selection, Selection.End(xlDown)).Select
    Selection.Copy
    Sheets("Notes").Select
    lastRow = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).Row + 1
    ActiveSheet.Paste
    Application.CutCopyMode = False
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
You are solving for lastRow, but then not using that calculation in determining where to paste your data.
What column are you trying to paste this data to?
If column A, try adding this line above your "ActiveSheet.Paste" line:
Code:
Range("A" & lastRow).Activate
 
Upvote 0
This pastes to the currently selected cell.
Code:
ActiveSheet.Paste

You should specify where to paste for example
Code:
Cells(lastRow,1).paste
 
Upvote 0
Replace the code as below

Code:
[COLOR=#333333]Dim lastRow As long[/COLOR]
    lastRow = Sheets("Notes").Cells(Rows.Count, "A").End(xlUp).Row + 1
    Range("D3").Select
    Range(Selection, Selection.End(xlDown)).Copy Sheets("Notes").Range("A" & lastRow)
 
Upvote 0
You are solving for lastRow, but then not using that calculation in determining where to paste your data.
What column are you trying to paste this data to?
If column A, try adding this line above your "ActiveSheet.Paste" line:
Code:
Range("A" & lastRow).Activate


I ended up going with this, however instead of .Activate, I used .Select
 
Upvote 0
I ended up going with this, however instead of .Activate, I used .Select
Either one will work. They essentially do the same thing.
 
Upvote 0
Odd. It worked for me.
Just go with whatever works for you.
 
Upvote 0

Forum statistics

Threads
1,215,274
Messages
6,123,993
Members
449,137
Latest member
abdahsankhan

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