Paste Values Only

jsturm

New Member
Joined
Sep 27, 2018
Messages
11
I have a simple operation where I am trying to essentialling copy a column of values from sheet Processed Compilation Tab to another sheet ATS Get Delete List.
It works ok but after this operation is done I do some filtering in the source sheet and what i am finding is that using the method below, once some of the values are filtered out my new column in ATS Get Delete List values are changing to #REF .

How can I use this method to permanently just paste the values over to my column in ATS Get Delete List?

Dim iLastrow As Long
Dim xsheet As Worksheet
Dim wb As Workbook

Set wb = ThisWorkbook
Set xsheet = wb.Sheets("Processed Compilation Tab")
iLastrow = xsheet.Cells(xsheet.Rows.Count, "Q").End(xlUp).Row ' -4162 value of xlup

Application.ScreenUpdating = False

Sheets("ATS Get Delete List").Range("W2:W" & iLastrow).Value = "=Trim(Clean('Processed Compilation Tab'!Q2))"
iLastrow = Sheets("ATS Get Delete List").Cells(Sheets("ATS Get Delete List").Rows.Count, "Z").End(xlUp).Row

Application.ScreenUpdating = True
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
Try
Code:
With Sheets("ATS Get Delete List").Range("W2:W" & iLastRow)
   .Value = "=Trim(Clean('Processed Compilation Tab'!Q2))"
   .Value = .Value
End With
 
Upvote 0
Awesome that worked great. I believe the only thing it changed then was my previous code had an effect to clear all cells W2:W in the process of pasting over the data.

Sometimes when I run this, there are less rows coming from the source sheet than the last time so I need to be sure all previous data is cleared out of the destination.
Would you recommend I just add a line for that to clear all contents from W:W & Last row in this case? When I tested this scenario as is now with only 250 rows being pasted in and the last time there was a 1000 rows, it left the data from the previous run.

If so, could you help me with the best way to state that 'clear contents' code?

Try
Code:
With Sheets("ATS Get Delete List").Range("W2:W" & iLastRow)
   .Value = "=Trim(Clean('Processed Compilation Tab'!Q2))"
   .Value = .Value
End With
 
Last edited:
Upvote 0
Would this work properly?

With Sheets("ATS Get Delete List").Range("W2:W" & iLastrow)
.Range("W2:W" & .Range("W2").End(xlDown).Row).ClearContents
.Value = "=Trim(Clean('Processed Compilation Tab'!Q2))"
.Value = .Value
End With
 
Upvote 0
Just add this
Code:
Range("W2:W" & Rows.Count).ClearContents
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,242
Members
452,623
Latest member
russelllowellpercy

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