I am trying to develop a macro in VBA to manage loaner vehicles for an automotive service department (see sample below). This is what I have put together so far, obviously it doesn't work:
Sub Duplicate_Entries_Based_on_Return_Date()
Dim lastrow As Long
'Find the Last Row
lastrow = Range("D3").CurrentRegion.Rows.Count
'Select Table
Range("D3:J" & lastrow).Select
'Filter Table
Selection.AutoFilter Field#4, Criteria1:=">Field#3"
'Copy/Paste
Selection.Copy
Sheets("March2019").Range("K3").PasteSpecial xlPasteValues
'Turn off autofilter
Selection.AutoFilter
End Sub
A critical component of the macro must be to compare the PICKUP DATE to the RETURN DATE, for each loaner vehicle, and automatically copy/paste the entry into the next day, or days, based on duration of repairs. It must also allow for the user to update return date(s) as needed. I have structured the workbook with separate sheets for each month. Each month data fields all run horizontally. Below is a snapshot of current format. Also, I have drop down menus, not sure if they will impact the macro.
Sub Duplicate_Entries_Based_on_Return_Date()
Dim lastrow As Long
'Find the Last Row
lastrow = Range("D3").CurrentRegion.Rows.Count
'Select Table
Range("D3:J" & lastrow).Select
'Filter Table
Selection.AutoFilter Field#4, Criteria1:=">Field#3"
'Copy/Paste
Selection.Copy
Sheets("March2019").Range("K3").PasteSpecial xlPasteValues
'Turn off autofilter
Selection.AutoFilter
End Sub
A critical component of the macro must be to compare the PICKUP DATE to the RETURN DATE, for each loaner vehicle, and automatically copy/paste the entry into the next day, or days, based on duration of repairs. It must also allow for the user to update return date(s) as needed. I have structured the workbook with separate sheets for each month. Each month data fields all run horizontally. Below is a snapshot of current format. Also, I have drop down menus, not sure if they will impact the macro.
Last edited by a moderator: