How can i add paste values to this vba code?

JumboCactuar

Well-known Member
Joined
Nov 16, 2016
Messages
785
Office Version
  1. 365
Platform
  1. Windows
Code:
Dim Last_Row As Long
Last_Row = Range("A1").End(xlDown).Offset(1).Row
Range("A1:N1").Copy Range("A" & Last_Row)
Sheets("Sheet1").Select
Range("A41").Select

I want to paste the values at A41 on sheet 1

I tried the below but it errors:
Code:
Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:= _ xlNone, SkipBlanks:=False, Transpose:=False

Thank-you
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
Code:
Dim Last_Row As Long
Last_Row = Range("A1").End(xlDown).Offset(1).Row
Range("A1:N1").Copy Range("A" & Last_Row)
Sheets("Sheet1").Select
Range("A41").Select

I want to paste the values at A41 on sheet 1

I tried the below but it errors:
Code:
Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:= _ xlNone, SkipBlanks:=False, Transpose:=False

Thank-you

Code:
Dim Last_Row As Long
Last_Row = Range("A1").End(xlDown).Offset(1).Row
Range("A1:N1").Copy 
Range("A" & Last_Row).PasteSpeccial xlPasteValues
Sheets("Sheet1").Select
Range("A41").Select
 
Upvote 0
Code:
Dim Last_Row As Long
Last_Row = Range("A1").End(xlDown).Offset(1).Row
Range("A1:N1").Copy 
Range("A" & Last_Row).PasteSpeccial xlPasteValues
Sheets("Sheet1").Select
Range("A41").Select

Thanks for the reply, ill try it shortly

It looks like the paste special is pasting over original rather data? Instead of pasting at A41 on sheet1
 
Upvote 0
This will put it in A41, my first post was just to show how to use the paste special.

Code:
Dim Last_Row As Long
Last_Row = Range("A1").End(xlDown).Offset(1).Row
Range("A1:N1").Copy 
Sheets("Sheet1").Range("A41").PasteSpeccial xlPasteValues
 
Upvote 0
This will put it in A41, my first post was just to show how to use the paste special.

Code:
Dim Last_Row As Long
Last_Row = Range("A1").End(xlDown).Offset(1).Row
Range("A1:N1").Copy 
Sheets("Sheet1").Range("A41").PasteSpeccial xlPasteValues

I tried this and now it just copies the first row?
 
Upvote 0
What do you mean now it only copies the first row?
That is all the Range("A1:N1") does in the code you posted in post #1 does.:confused:
 
Upvote 0
What do you mean now it only copies the first row?
That is all the Range("A1:N1") does in the code you posted in post #1 does.:confused:

yes a mistake in my coding but with this line:

with me having this line i thought people would know what im trying to do
Last_Row = Range("A1").End(xlDown).Offset(1).Row


i simply want all data in columns A:N copied to sheet 1
 
Last edited:
Upvote 0
i thought people would know what im trying to do
You are using the line you posted as the destination sheets variable not part of the copy range and so no people aren't psychic and so don't know what you are trying to do without you actually stating it.

What exactly are you trying to do?
Are you trying to copy the range A1 to N where column A is the longest column? or are you basing the last row on another longest column ? or are you basing ithe last row on the longest column whichever column it is within the range?

Then are you trying to paste it in the next row based on the next empty cell in column A in the destination sheet?

Finally what are both sheets names?
 
Last edited:
Upvote 0
You are using the line you posted as the destination sheets variable not part of the copy range and so no people aren't psychic and so don't know what you are trying to do without you actually stating it.

What exactly are you trying to do?
Are you trying to copy the range A1 to N where column A is the longest column? or are you basing the last row on another longest column ? or are you basing ithe last row on the longest column whichever column it is within the range?

Then are you trying to paste it in the next row based on the next empty cell in column A in the destination sheet?

Finally what are both sheets names?

Sheet 2
Columns A to N have data but row count varies.
So copy from A1 down to N(last row)

Then paste values on Sheet 1 at A41

This is what i had to start with to ensure i grabbed it all but i just want a way to not select the blanks
Code:
Sheets("Sheet2").Select
Range("A1:N1000").Copy
Sheets("Sheet1").Select)
Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:= _ xlNone, SkipBlanks:=False, Transpose:=False
 
Last edited:
Upvote 0
Columns A to N have data but row count varies.

I will try again... what determines how the row count varies...

Are you trying to copy the range A1 to N where column A is the longest column? or are you basing the last row on another longest column ? or are you basing the last row on the longest column whichever column it is within the range?

Be specific on how the longest row is determined.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,999
Messages
6,122,645
Members
449,093
Latest member
Ahmad123098

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