PDA

View Full Version : [SOLVED:] Setting a cell range then hiding rows with a certain value.



jamesg
08-07-2011, 08:31 PM
Hi All,

Am working Excel 07/Vista and looking for a macro that will.....

1. Find the last populated cell in column A and set a range eg A3:Ax
2. Then hide all rows for an adjacent range (Clolumn C3: Cx) that have the value "N" in them.

Regards
James

GTO
08-08-2011, 04:47 AM
Greetings James,

Note that I am using the sheet's CodeName. Try:
Option Explicit

Sub exa()
Dim rng As Range
Dim lLRow As Long
Dim i As Long

Application.ScreenUpdating = False
With Sheet1
lLRow = .Cells(.Rows.Count, 1).End(xlUp).Row
For i = lLRow To 3 Step -1
If .Cells(i, 2).Value = "N" Then
.Rows(i).Hidden = True
End If
Next
End With
Application.ScreenUpdating = True
End Sub
Hope that helps,

Mark