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

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
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
 
Upvote 0
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
 
Upvote 0
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
 
Upvote 0
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
 
Upvote 0
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".
 
Upvote 0
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
 
Upvote 0

Forum statistics

Threads
1,214,971
Messages
6,122,517
Members
449,088
Latest member
RandomExceller01

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