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

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest

Forum statistics

Threads
1,223,908
Messages
6,175,305
Members
452,633
Latest member
DougMo

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