Insert blank row after last series # in []

BradMS

New Member
Joined
Jan 27, 2017
Messages
32
how would I go about adding blanks rows after every square bracket when it switches from [1] , [2]....? (where the red line is)

I would like it to start at B2 after the series of [1] add a spaces then after the series of [2] add a space and so fourth.
Up until it reaches a blank and it ends.


View attachment 49417

This is what I found to work, but I need to tell it how many [1] I have. In the image I have [4]

VBA Code:
Public Sub InsertRows()

Dim answer As Integer
Dim Lastrow As Long

'question
answer = InputBox("Total points?")

i = answer

x = 2 'Start Row
    
Range("A" & x, "F" & x).Insert

x = x + i + 1

Do Until IsEmpty(Cells(x, 1))

Range("A" & x, "F" & x).Insert

x = x + i + 1

Loop
  
End Sub
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
VBA Code:
Sub AddRows()
    Dim i As Long, B, strRange As String
    B = Range(Cells(2, 2), Cells(2, 2).End(xlDown))
    For i = 2 To UBound(B)
        If Right(B(i, 1), 2) <> Right(B(i - 1, 1), 2) Then
            strRange = strRange & ",A" & i + 1 & ":F" & i + 1
        End If
    Next
    Range(Right(strRange, Len(strRange) - 1)).Insert
End Sub
 
Upvote 0
VBA Code:
Sub AddRows()
    Dim i As Long, B, strRange As String
    B = Range(Cells(2, 2), Cells(2, 2).End(xlDown))
    For i = 2 To UBound(B)
        If Right(B(i, 1), 2) <> Right(B(i - 1, 1), 2) Then
            strRange = strRange & ",A" & i + 1 & ":F" & i + 1
        End If
    Next
    Range(Right(strRange, Len(strRange) - 1)).Insert
End Sub
Thankyou! i will try it later today!
 
Upvote 0

Forum statistics

Threads
1,214,606
Messages
6,120,488
Members
448,967
Latest member
visheshkotha

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