VBA Paste to last row

thedeadzeds

Active Member
Joined
Aug 16, 2011
Messages
451
Office Version
  1. 365
Platform
  1. Windows
Guys, How do i change the below to paste as value to the last row of the Sheets("BA Audi SMOT NC Values")


Code:
Sheets("BA Polk Audi Serv & MOT N Calls").Select    Cells.Select
    Selection.Copy
    Sheets("BA Audi SMOT NC Values").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Hi,

You need to be more specific with the range to copy:

Cells.copy copy the entire page and can only be paste in a1.
If we can check column A to identify the last row, then we would use (you can adapt the letter)
Code:
[COLOR=#3D3D3D][FONT='inherit']Dim LastRow as long

LastRow = Worksheets[/FONT][/COLOR][COLOR=#333333]("BA Polk Audi Serv & MOT N Calls")[/COLOR][COLOR=#3D3D3D][FONT='inherit'].Cells([/FONT][/COLOR][COLOR=#3D3D3D][FONT='inherit']Worksheets[/FONT][/COLOR][COLOR=#333333]("BA Polk Audi Serv & MOT N Calls")[/COLOR][COLOR=#3D3D3D][FONT='inherit'].Rows.Count, "A").End(xlUp).Row[/FONT][/COLOR]

So your code would look like

Code:
Sub test()
Dim LastRow As Long
 LastRow = Worksheets("BA Audi SMOT NC Values").Cells(Worksheets("BA Audi SMOT NC Values").Rows.Count, "A").End(xlUp).Row
    Sheets("BA Audi SMOT NC Values").Select
    Range("A"&Lastrow+1).Select

 LastRow = Worksheets("BA Polk Audi Serv & MOT N Calls").Cells(Worksheets("BA Polk Audi Serv & MOT N Calls").Rows.Count, "A").End(xlUp).Row
    Sheets("BA Polk Audi Serv & MOT N Calls").Rows("1:" & LastRow).Copy
    Selection.PasteSpecial Paste:=xlPasteValues
End Sub
 
Last edited:
Upvote 0
"to paste as value to the last row " or the row AFTER the last row ???
 
Upvote 0
If yes to previous question, see next code
Code:
Sub Test()
    Sheets("BA Polk Audi Serv & MOT N Calls").Cells(1, 1).CurrentRegion.Copy
    Sheets("BA Audi SMOT NC Values").Cells(Rows.Count, 1).End(3)(2).PasteSpecial _
          Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
End Sub
 
Upvote 0
"to paste as value to the last row " or the row AFTER the last row ???

To the row
Code:
[COLOR=#333333]Range("A"&Lastrow).Select[/COLOR]

To the next
Code:
[COLOR=#333333]Range("A"&Lastrow+1).Select[/COLOR]
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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