Update Date and O/D When Running Code

L

Legacy 436357

Guest
Hello,

Can code be modified to update the Date and O/D in columns A and B from C and D with the most current ones?

Thank you very much for your help


Excel Workbook
ABCD
1Last DateLast O/DNew DateNew O/D
27/1/20186000010/19/201870000
37/1/20186000010/19/201870000
47/1/20186000010/19/201870000
2011 Ford F150


Code:
Sub CopyPasteRows3()




    Dim lr As Long
    Dim r As Long
    Dim nr As Long
    
    Application.ScreenUpdating = False
    
'   Find last row with data in column on Sheet2
    lr = Sheets("2014 Dodge Dart").Cells(Rows.Count, "C").End(xlUp).Row
    
'   Loop through all rows starting on row 2 on Sheet2
    For r = 2 To lr
        If Sheets("2014 Dodge Dart").Cells(r, "L") = True Then
'           Find next available row on Sheet1
            nr = Sheets("Service Log").Cells(Rows.Count, "C").End(xlUp).Row + 1
'           Copy data to from columns C-G to Sheet2
            Sheets("2014 Dodge Dart").Range("C" & r).Resize(, 5).Copy
'           Paste values from columns C-G to Sheet1
            Sheets("Service Log").Cells(nr, "C").PasteSpecial xlPasteValues
'           Remove checkbox from Sheet2
            Sheets("2014 Dodge Dart").Cells(r, "L") = False
        End If
    Next r
    
    Application.ScreenUpdating = True
    Application.CutCopyMode = False
    MsgBox "Macro Done!"
    
End Sub
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.

Forum statistics

Threads
1,224,836
Messages
6,181,252
Members
453,028
Latest member
letswriteafairytale

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