Grouping Question

R

ryguy7272

I am trying to find a way to group rows, according to the following logic:

Start in row 9

Test to see if there are two, or four, blank spaces in a cell, preceding
text. If there are two blank spaces in a cell, move to the next cell. When
a cell has four spaces, group that with the cells above. Move on to test the
next cell.

If a cell is found with no data at all, this is a totally blank cell; offset
one row down, and continue the process, until 2, or maybe 3, blank rows are
in consecutive order.

I have this now:

Sub Grp()
Dim rng As Range
Dim i As Long
Sheets("Sheet1").Select
For i = 9 To Cells(Rows.Count, "B").End(xlUp).Row
If Len(ActiveCell) > 0 Then
Rows(i).Group
Else
End If
Next i
End Sub

Thanks so much,
Ryan---
 
J

Jacob Skaria

I am not sure whether I understood your post clearly..Please try and feedback

Sub Grp()
Dim lngRow As Long
Sheets("Sheet1").Select
For lngRow = 9 To Cells(Rows.Count, "B").End(xlUp).Row
If Range("B" & lngRow) <> "" And Left(Range("B" & lngRow), 4) = Space(4) Then
Range("B" & lngRow - 1 & ":B" & lngRow).Rows.Group
End If
Next lngRow
End Sub

If this post helps click Yes
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top