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
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 | ||||||
---|---|---|---|---|---|---|
A | B | C | D | |||
1 | Last Date | Last O/D | New Date | New O/D | ||
2 | 7/1/2018 | 60000 | 10/19/2018 | 70000 | ||
3 | 7/1/2018 | 60000 | 10/19/2018 | 70000 | ||
4 | 7/1/2018 | 60000 | 10/19/2018 | 70000 | ||
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