How to group blank rows

jltromb

New Member
Joined
Mar 31, 2017
Messages
5
Hello!

I have a sheet full of data. In column A there are many rows with blank cells. I'd like to collapse (group) them up to the previous row that contains data.

The goal is to have all data showing where there is a value in Column A. The user could then click the "+" next to that row and expand the data (I have an ADO recordset placing the data appropriately, so expanded rows would be related to the row in view).

I'm sure the answer lies in Range.Rows.Group but I haven't been able to make it work - any ideas?

Thanks,
Jim

 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
As a follow up - this code is working well but the "+" isn't on the line that corresponds to the data to be expanded. It's on the row below it!

Code:
    For i = 1 To (rs.recordCount * 2)
        If Range("A" & i).Value = "" Then
            Range("A" & i).Rows.Group
        End If
    Next i
 
Upvote 0
As a follow up - this code is working well but the "+" isn't on the line that corresponds to the data to be expanded. It's on the row below it!

Code:
    For i = 1 To (rs.recordCount * 2)
        If Range("A" & i).Value = "" Then
            Range("A" & i).Rows.Group
        End If
    Next i
Thanks. Your code helped me a lot.

Data->Outline options->uncheck " Summary rows below detail" box.

"+" will be on the line that data needs to be expanded

1603454152257.png
 
Upvote 0

Forum statistics

Threads
1,216,075
Messages
6,128,662
Members
449,462
Latest member
Chislobog

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