PasteValue Help

kermitfrog123

Board Regular
Joined
Dec 19, 2015
Messages
50
Afternoon All,

I am currently using the below code which works perfectly. However, my requirements have changed and I now need to destination data to be sent as values only. Can anyone help me achieve this please?

Code:
    Worksheets("All").Select    
    Dim LR As Long, i As Long
    LR = Range("A" & Rows.Count).End(xlUp).Row
    For i = 2 To LR
    If Range("AD" & i).Value = "NextDay" Then Rows(i).Cut Destination:=Sheets("Interlink").Range("A" & Rows.Count).End(xlUp).Offset(1)
    Next i
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
Instead of cutting the range (which really takes everything including formulas) why not try to take only the values of that range?

also, the way your current code is set up, once you find a value, you cut that value, which shifts all your cells up, and then you go to the next row (which has now moved). In return, by going to the next row you actually are skipping a row. So really, your code was incomplete. (i think anyway - I didnt test it. If I am wrong please correct me :p)

The below code has not been tested, but I just copied your exact code and used a special paste for only values (no formulas) and then deleted the original row. After that I removed one row from your count and then continued to the next one down the list. This way you are not missing any values in your looping.

You might want to look up special pasting


Code:
   worksheets("A11").select
   dim lr as long, i as long
   lr = range("a" & rows.count).end(x1up).row
   for i = 2 to lr
   if range(ad" & i). value = "NextDay" then
      rows(i).copy
      sheets("Interlink").range("A" & rows.count).end(x1up).offset(1).pastespecial xlpastevalues
      rows(i).delete
      i - i - 1
      lr = lr - 1
   end if

hope that helps
~frab
 
Last edited:
Upvote 0

Forum statistics

Threads
1,196,366
Messages
6,014,843
Members
441,850
Latest member
peh16

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