Insert Blank Rows

colmguckian

New Member
Joined
Feb 11, 2011
Messages
35
Hi
I am looking for a macro to count the number of blank rows immediately before Cell A12.
If the number of blank rows is less than 10 then I would like to insert blank rows until there are 10 blank Rows Inserted.
Can anybody help please.
 
Last edited:

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
Are you only looking at entries in column A to determine if a row is blank, or might other columns come into play also?
If so, what are your possible columns with entries?
 
Upvote 0
Maybe something like this?
Code:
Sub MyInsertRows()
 
    Dim myBlankCount As Integer
    Dim cell As Range
    
'   Count blank rows in range A1:A11
    For Each cell In Range("A1:A11")
        If Len(cell) = 0 Then myBlankCount = myBlankCount + 1
    Next cell
    
'   Insert blank rows starting at row 11
    If myBlankCount < 10 Then Rows("11:" & 11 + (9 - myBlankCount)).EntireRow.Insert
    
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,596
Messages
6,179,807
Members
452,943
Latest member
Newbie4296

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