View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
Gord Dibben Gord Dibben is offline
external usenet poster
 
Posts: 22,906
Default unhiding and hiding rows

How will C5 get changed from P to L?

What column or columns would the P's C's and L's be located?

This macro will hide all rows then unhide according to value in C5.

I used column D as the column in which the letters will be found.

Tweak as necessary.

Sub hide_rows()
Dim RowNdx As Long
Dim LastRow As Long
ActiveSheet.Rows.Hidden = True
LastRow = ActiveSheet.UsedRange.Rows.Count
For RowNdx = LastRow To 1 Step -1
If Range("C5").Value = "L" And _
Cells(RowNdx, "D").Value = "L" Or _
Cells(RowNdx, "D").Value = "C" Then
Rows(RowNdx).Hidden = False
ElseIf Range("C5").Value = "P" And _
Cells(RowNdx, "D").Value = "P" Or _
Cells(RowNdx, "D").Value = "C" Then
Rows(RowNdx).Hidden = False
End If
Next RowNdx
End Sub


Gord Dibben MS Excel MVP

On Wed, 5 Mar 2008 09:35:02 -0800, Paul_of_Abingdon
wrote:

I would like to see only those rows which value matches with master cell. for
example, if C5=P, I want to see only those rows which has value of P or C.
Similary, if the value C5=L, then I want to see only those rows which has
value of L and C. Category C is common rows. So, I need to see them no matter
what is in C5. Thanks in advance for your help.