Paste Values Only

Scole1

New Member
Joined
Sep 15, 2020
Messages
6
Office Version
  1. 2013
Platform
  1. Windows
I need to paste values only from cells. I have a open workbook and close workbook command that runs. The macro works perfect except it brings over the formulas

Sub CopyPaste1st()

'Find the last used row in both sheets and copy and paste data below existing data.

Dim wsCopy As Worksheet
Dim wsDest As Worksheet
Dim lCopyLastRow As Long
Dim lDestLastRow As Long

'Set variables for copy and destination sheets
Set wsCopy = ThisWorkbook.Worksheets("1st-SHIFT")
Set wsDest = Workbooks("Data File.xlsx").Worksheets("Shift Data")

'1. Find last used row in the copy range based on data in column A
lCopyLastRow = wsCopy.Cells(wsCopy.Rows.Count, "A").End(xlUp).Row

'2. Find first blank row in the destination range based on data in column A
'Offset property moves down 1 row
lDestLastRow = wsDest.Cells(wsDest.Rows.Count, "A").End(xlUp).Offset(1).Row

'3. Copy & Paste Data
wsCopy.Range("A100:AG101").Copy _
wsDest.Range("A1" & lDestLastRow)


End Sub
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
60,136
Office Version
  1. 365
Platform
  1. Windows
Try changing this:
VBA Code:
'3. Copy & Paste Data
wsCopy.Range("A100:AG101").Copy _
wsDest.Range("A1" & lDestLastRow)
to this:
VBA Code:
'3. Copy & Paste Data
wsCopy.Range("A100:AG101").Copy
wsDest.Range("A1").PasteSpecial xlPasteValues
 

Scole1

New Member
Joined
Sep 15, 2020
Messages
6
Office Version
  1. 2013
Platform
  1. Windows
Try changing this:
VBA Code:
'3. Copy & Paste Data
wsCopy.Range("A100:AG101").Copy _
wsDest.Range("A1" & lDestLastRow)
to this:
VBA Code:
'3. Copy & Paste Data
wsCopy.Range("A100:AG101").Copy
wsDest.Range("A1").PasteSpecial xlPasteValues
It needs to go to next available line on the new sheet and the paster special above doesnt work either way I write it.

All Lines are red

'3. Copy & Paste Data
wsCopy.Range("A100:AG101").Copy _
wsDest.Range("A" & lDestLastRow).PasteSpecial xlPasteValues
or

wsCopy.Range("A100:AG101").Copy _
wsDest.Range("A1").PasteSpecial xlPasteValues

This one doesnt work either

wsCopy.Range("A100:AG101").Copy _
wsDest.Range("A1").PasteSpecial :=xlPasteValues

or

wsCopy.Range("A100:AG101").Copy _
wsDest.Range("A" & lDestLastRow).PasteSpecial :=xlPasteValues
 

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
60,136
Office Version
  1. 365
Platform
  1. Windows
OK, I was just working off of your existing code, not realizing that you actually had an error in it.
This row you have:
VBA Code:
wsDest.Range("A1" & lDestLastRow)
should have been this:
VBA Code:
wsDest.Range("A" & lDestLastRow)
since you are dynamically finding the row number, you do not want to carry over row number "1" from "A1".

So try this:
VBA Code:
'3. Copy & Paste Data
wsCopy.Range("A100:AG101").Copy
wsDest.Range("A" & lDestLastRow).PasteSpecial xlPasteValues
 

Scole1

New Member
Joined
Sep 15, 2020
Messages
6
Office Version
  1. 2013
Platform
  1. Windows

ADVERTISEMENT

OK, I was just working off of your existing code, not realizing that you actually had an error in it.
This row you have:
VBA Code:
wsDest.Range("A1" & lDestLastRow)
should have been this:
VBA Code:
wsDest.Range("A" & lDestLastRow)
since you are dynamically finding the row number, you do not want to carry over row number "1" from "A1".

So try this:
VBA Code:
'3. Copy & Paste Data
wsCopy.Range("A100:AG101").Copy
wsDest.Range("A" & lDestLastRow).PasteSpecial xlPasteValues
Ya sorry color doesnt paste over

Copy & Paste Data
wsCopy.Range("A100:AC101").Copy _
wsDest.Range("A" & lDestLastRow) .PasteSpecial xlPasteValues


Did this and still getting a compile error
 

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
60,136
Office Version
  1. 365
Platform
  1. Windows
Ya sorry color doesnt paste over

Copy & Paste Data
wsCopy.Range("A100:AC101").Copy _
wsDest.Range("A" & lDestLastRow) .PasteSpecial xlPasteValues


Did this and still getting a compile error
That is because you have not structured it like I showed you.
Look closely at what I posted.
There is no "_" after the word "Copy".
 

Scole1

New Member
Joined
Sep 15, 2020
Messages
6
Office Version
  1. 2013
Platform
  1. Windows
That is because you have not structured it like I showed you.
Look closely at what I posted.
There is no "_" after the word "Copy".
Thank you worked perfect. I completly missed that
 

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
60,136
Office Version
  1. 365
Platform
  1. Windows
You are welcome.
 

Forum statistics

Threads
1,148,237
Messages
5,745,566
Members
423,960
Latest member
sainoz

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
Top