KEMBAR78
Add Blank Row After Every Row | PDF
0% found this document useful (0 votes)
13 views2 pages

Add Blank Row After Every Row

The document contains three VBA macros for Excel. The first macro inserts a blank row after every existing row, the second inserts a blank row after every four rows, and the third adds borders to filled rows only. Each macro utilizes loops and worksheet functions to manipulate the active sheet accordingly.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views2 pages

Add Blank Row After Every Row

The document contains three VBA macros for Excel. The first macro inserts a blank row after every existing row, the second inserts a blank row after every four rows, and the third adds borders to filled rows only. Each macro utilizes loops and worksheet functions to manipulate the active sheet accordingly.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

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

You might also like