Question Regarding ShowDetail.

D

Dan

Hi,

I have a macro that when user calls it, it will do a
group of the rows that have the same equivalent field.
Though, when I run this macro, the macro finishes by
leaving the worksheet showing all the details. So what I
want to do it is to code in VBA to not show details. I
tried using Rows("[PUT RANGE HERE]").ShowDetail=False,
but it doesn't work. Since the groups are scattered out
through the worksheet, I need to call this Rows("[PUT
RANGE HERE]").ShowDetail=False in a while loop, but only
the first time its called it works and it crashes the
second time. Is there anyway to fix this?

The code I have is:
 
P

Peter Atherton

Dan

Do you need to group the data? I usually do this on sorted
data with subtotals. The following will just hide the rows
(change the criterion (ISEmpty) to suit).

Sub test()
Dim rng As Range
Dim c
Set rng = Range("c3:c15")
' unhide previously hidden rows
rng.EntireRow.Hidden = False
For Each c In rng
If IsEmpty(c) Then
c.Rows.Hidden = True
End If
Next c

End Sub
 

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