Excel macros

Closed
bkballer2000 Posts 1 Registration date Thursday February 12, 2009 Status Member Last seen February 13, 2009 - Feb 13, 2009 at 02:06 PM
 Helper - Feb 13, 2009 at 03:10 PM
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
Related:

1 response

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
0