Add blank row after every row
Sub InsertBlankRows()
Dim ws As Worksheet
Dim lastRow As Long
Dim i As Long
Set ws = ActiveSheet
lastRow = ws.Cells(ws.Rows.Count, 1).End(xlUp).Row
' Loop from bottom to top
For i = lastRow To 2 Step -1
ws.Rows(i).Insert Shift:=xlDown
Next i
End Sub
Add blank row after every 4 rows
Sub InsertBlankRowEvery4()
Dim ws As Worksheet
Dim lastRow As Long
Dim i As Long
Dim interval As Long
Set ws = ActiveSheet
interval = 4 ' Insert after every 4 rows
lastRow = ws.Cells(ws.Rows.Count, 1).End(xlUp).Row
' Loop from bottom to top to avoid offset issues
For i = lastRow To interval + 1 Step -interval
ws.Rows(i + 1).Insert Shift:=xlDown
Next i
End Sub
Add boarders to filled rows only
Sub AddBordersToFilledRows()
Dim ws As Worksheet
Dim lastRow As Long
Dim r As Long
Dim lastCol As Long
Dim cellRange As Range
Set ws = ActiveSheet
lastRow = ws.Cells(ws.Rows.Count, 1).End(xlUp).Row
lastCol = ws.Cells(1, ws.Columns.Count).End(xlToLeft).Column
For r = 1 To lastRow
If Application.WorksheetFunction.CountA(ws.Rows(r)) > 0 Then
Set cellRange = ws.Range(ws.Cells(r, 1), ws.Cells(r, lastCol))
With cellRange.Borders
.LineStyle = xlContinuous
.Color = RGB(0, 0, 0)
.Weight = xlThin
End With
End If
Next r
End Sub