Insert blank row after last series # in []

BradMS

New Member
Joined
Jan 27, 2017
Messages
31
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

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".

JGordon11

Active Member
Joined
Jan 18, 2021
Messages
472
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
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
 

BradMS

New Member
Joined
Jan 27, 2017
Messages
31
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!
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,164,139
Messages
5,835,633
Members
430,372
Latest member
contentment

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
Top