View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
leonidas[_8_] leonidas[_8_] is offline
external usenet poster
 
Posts: 1
Default hide and unhide rows


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

--
leonida
-----------------------------------------------------------------------
leonidas's Profile: http://www.excelforum.com/member.php...fo&userid=3537
View this thread: http://www.excelforum.com/showthread.php?threadid=55220