Paste Values Instead of Formulas

L

Legacy 436357

Guest
Hello I have this code derived in this forum but it pastes the rows with formulas. Can it be altered so it pastes the values of the cells?

Thank you for your help

Code:
Sub MyMacro()


    Dim lr As Long
    Dim r As Long
    Dim nr As Long
    
    Application.ScreenUpdating = False
    
'   Find last row with data in column A on Sheet1
    lr = Sheets("Sheet1").Cells(Rows.Count, "A").End(xlUp).Row
    
'   Loop through all rows starting on row 2 on Sheet1
    For r = 2 To lr
        If Sheets("Sheet1").Cells(r, "L") = True Then
'           Find next available row on Sheet2
            nr = Sheets("Sheet2").Cells(Rows.Count, "A").End(xlUp).Row + 1
'           Copy data to from columns A-L to sheet2
            Sheets("Sheet1").Range(Cells(r, "A"), Cells(r, "L")).Copy Sheets("Sheet2").Cells(nr, "A")
'           Remove checkbox from sheet 1
            Sheets("Sheet1").Cells(r, "L") = False
        End If
    Next r
    
    Application.ScreenUpdating = True
    
    MsgBox "Macro Done!"
    
End Sub
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
Try this.
Code:
Sub MyMacro()


    Dim lr As Long
    Dim r As Long
    Dim nr As Long
    
    Application.ScreenUpdating = False
    
'   Find last row with data in column A on Sheet1
    lr = Sheets("Sheet1").Cells(Rows.Count, "A").End(xlUp).Row
    
'   Loop through all rows starting on row 2 on Sheet1
    For r = 2 To lr
        If Sheets("Sheet1").Cells(r, "L") = True Then
'           Find next available row on Sheet2
            nr = Sheets("Sheet2").Cells(Rows.Count, "A").End(xlUp).Row + 1
'           Copy data to from columns A-L to sheet2
            Sheets("Sheet1").Range("A" & r).Resize(,12).Copy 
            Sheets("Sheet2").Cells(nr, "A").PasteSpecial xlPasteValues
'           Remove checkbox from sheet 1
            Sheets("Sheet1").Cells(r, "L") = False
        End If
    Next r
    
    Application.ScreenUpdating = True
    
    MsgBox "Macro Done!"
    
End Sub
 
Upvote 0
Thank you that works but one thing though. The last row is flashing from the source sheet like it's ready to be copied when running the code.
 
Upvote 0
Add this at the end of the code.
Code:
Application.CutCopyMode = False
 
Upvote 0
Perfect thank you very much for your help.

I am learning valuable lessons here hopefully I can pay it forward.
 
Upvote 0

Forum statistics

Threads
1,214,606
Messages
6,120,497
Members
448,967
Latest member
visheshkotha

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