Sunday, August 14, 2011

Hiding Rows :

If you want to Hide Rows on Excel Worksheet if any cell value match with Your Criteria in Selection You can use this Code :



Option Compare Text
Sub HidingMatchingRows()
Application.ScreenUpdating = False
Dim rng As Range
If TypeName(Selection) = "Range" Then
Set rng = Selection
Else
MsgBox "Select Some Range", vbInformation
Exit Sub
End If
        
        For r = 1 To rng.Rows.Count
            For c = 1 To rng.Columns.Count
                If rng.Cells(r, c).Value = "Rajan" Then rng.Cells(r, c).EntireRow.Hidden = True
                Next
        Next
Application.ScreenUpdating = True
End Sub

No comments: