inserting blank line coding issue

Enzo_Matrix

Board Regular
Joined
Jan 9, 2018
Messages
113
I have this code supplied by a board regular and it works perfectly apart from one minor bug.

I have a table being used for our production schedule with the date as the main focal point. This table is updated regularly throughout each day and items are both removed and added. The code is supposed to add a blank line at the end of each week to better seperate our work load.

Code:
Dim i As Long
    Col = "G"
For i = LR To 5 Step -1    If Cells(i, Col).Value >= Date Then
        On Error Resume Next
            If Cells(i, Col).Value - Cells(i - 1, Col).Value > 1 Then
                On Error GoTo 0
                Cells(i, Col).EntireRow.Insert
            End If
    End If
Next i

This code is adding additional blank lines though and I have to manually delete them. Is there a way to either have some script delete the last row for me or to modify this code so that it will do it on its own?
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.

Forum statistics

Threads
1,214,422
Messages
6,119,396
Members
448,891
Latest member
tpierce

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