hide and unhide rows

L

leonidas

Hi,

I have the following situation in excel:
I have a worksheet with a lot of data (text) in colomn B. This data i
split in pieces with above and beneath every piece an empty cell. I us
textboxes to assign macros to hide and unhide the pieces of data. Th
VBA code of one of these macros is:

Sub ProcessGroup5()

Dim rw As Long
rw = 5
Hide_or_Unhide rw

End Sub

Sub Hide_or_Unhide(rw As Long)

Dim rng As Range, i As Long, j As Long
Dim ar As Range
Set rng = Columns(2).SpecialCells(xlConstants, xlTextValues)
i = 0
j = 0
For Each ar In rng.Areas
i = i + 1
If i = rw Then
j = WorksheetFunction.CountIf(ar.Offset(0, 4), "*")
If j > 0 And ar.EntireRow.Hidden = False Then
Cells(ar.Row, "J").Select
Else
ar.EntireRow.Hidden = Not ar.EntireRow.Hidden
If ar.EntireRow.Hidden = True Then
Cells(ar.Row - 1, "J").Select
Else: Cells(ar.Row, "J").Select
End If
End If
Exit Sub
End If
Next

End Sub

There is only one problem.
Column F is never really empty, there is a formula in it and there i
only an outcome when there is a number in both column J and M. Wit
this code above Column F has to be empty to hide the rows.
Does someone have a solution for this? Thanks in advance
 

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