Change VB code to move as values, instead of formulas

Rob_010101

Board Regular
Joined
Jul 24, 2017
Messages
208
Office Version
  1. 365
Platform
  1. Windows
Hello

The below code moves rows of data to an archive sheet when they become 6 months old (as of the current date).

Could someone help me change it so it moves the data as values, rather than formulas?

VBA Code:
Private Sub Workbook_Open()

    Application.ScreenUpdating = False
    
    'Set worksheet variables
    Dim WsC6 As Worksheet, WsP6 As Worksheet
    Set WsC6 = Worksheets("PAYE Sickness (Current 6)")
    Set WsP6 = Worksheets("PAYE Sickness (Archive)")
    
    'Move old records from the PAYE Sickness (Current 6) sheet first
    Dim d As Date, d2 As Date, LRow As Long
    d = WorksheetFunction.EDate(Date, -6)
    d = Format(d, "dd/mm/yyyy")
    LRow = WsP6.Cells(Rows.Count, 1).End(3).Row + 1
    With WsC6.Range("A1").CurrentRegion
        .AutoFilter 10, "<" & CDbl(d)
        If WsC6.Cells(Rows.Count, 1).End(xlUp).Row > 1 Then
            .Offset(1).Resize(.Rows.Count - 1).Copy WsP6.Cells(LRow, 1)
            .Offset(1).Resize(.Rows.Count - 1).EntireRow.Delete
        End If
        WsC6.ShowAllData
    End With
    
    Application.ScreenUpdating = True
        Sheets("PAYE Sickness (Current 6)").Select
  Range("I1:I" & Range("I" & Rows.Count).End(3).Row + 1).Find("", Range("I1"), xlValues, xlWhole).Select
End Sub

Many Thanks
 
Hello,
You can edit this part of the code like so
VBA Code:
        If WsC6.Cells(Rows.Count, 1).End(xlUp).Row > 1 Then
            .Offset(1).Resize(.Rows.Count - 1).Copy
            WsP6.Cells(LRow, 1).PasteSpecial xlPasteValues
            Application.CutCopyMode = False
            .Offset(1).Resize(.Rows.Count - 1).EntireRow.Delete
        End If
 
Upvote 0
Solution
Hello,
You can edit this part of the code like so
VBA Code:
        If WsC6.Cells(Rows.Count, 1).End(xlUp).Row > 1 Then
            .Offset(1).Resize(.Rows.Count - 1).Copy
            WsP6.Cells(LRow, 1).PasteSpecial xlPasteValues
            Application.CutCopyMode = False
            .Offset(1).Resize(.Rows.Count - 1).EntireRow.Delete
        End If
Thank you!
 
Upvote 0

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