I currenlty have code that if column I contains a length greater than 2 to duplicate the entire row and paste directly below that line.
However, I could use some help with the other part of the code. I need column J of the new row to equal the cell value in column K of the above (original) row. ONLY on the new duplicate row. I also need the start time and end time in columns M & N to reflect the new quantity hour(s) in the new row. * the new time range should not exceed the original end time.
Here is the current structure of my file:
This is how I need the code to look like:
Here is my current code:
Sub MealFix()
Dim wb As Workbook: Set wb = ThisWorkbook
Dim ws As Worksheet
Set ws = wb.Sheets("Procore Process Master")
Dim Lastrow As Long
Dim r As Long
Lastrow = ws.Range("B" & Rows.Count).End(xlUp).row
For r = Lastrow To 2 Step -1
If Len(ws.Cells(r, 11).Value) > 2 Then
ws.Cells(r, 1).EntireRow.Offset(1).Insert
ws.Cells(r, 1).EntireRow.Copy Destination:=ws.Cells(r, 1).Offset(1)
End If
Next r
End Sub
However, I could use some help with the other part of the code. I need column J of the new row to equal the cell value in column K of the above (original) row. ONLY on the new duplicate row. I also need the start time and end time in columns M & N to reflect the new quantity hour(s) in the new row. * the new time range should not exceed the original end time.
Here is the current structure of my file:
This is how I need the code to look like:
Here is my current code:
Sub MealFix()
Dim wb As Workbook: Set wb = ThisWorkbook
Dim ws As Worksheet
Set ws = wb.Sheets("Procore Process Master")
Dim Lastrow As Long
Dim r As Long
Lastrow = ws.Range("B" & Rows.Count).End(xlUp).row
For r = Lastrow To 2 Step -1
If Len(ws.Cells(r, 11).Value) > 2 Then
ws.Cells(r, 1).EntireRow.Offset(1).Insert
ws.Cells(r, 1).EntireRow.Copy Destination:=ws.Cells(r, 1).Offset(1)
End If
Next r
End Sub