Excel macros

[Closed]
Report
Posts
1
Registration date
Thursday February 12, 2009
Status
Member
Last seen
February 13, 2009
-
 Helper -
Hello,
how to code an excel macro where an if staement will hide appropriate rows? Any suggestions would be greatly appreciated.


1. Yes
2. ---
3. ---
4. Yes
5. ---
6. ---

I need a macro that will locate the rows with the word Yes and hide all of the other rows.

Thank you

1 reply

This assumes that the word "YES" is in column A.


Private Sub HideRows()


Dim intLastRow As Integer
Dim intRow As Integer

intLastRow = Range("A65536").End(xlUp).Row

For intRow = intLastRow To 1 Step -1

Rows(intRow).Select
If Cells(intRow, 1).Value <> "YES" Then
Cells(intRow, 1).Select
Selection.EntireRow.Hidden = True
End If

Next intRow

End Sub