Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Hide Rows meeting condition Amendment
Can some one amend the following code to substitute 2 to 10000 to a named range
"CondRange" (for condition range) -- Dim i%, rng As Range Set rng = Sheets("Staff").Cells(1, 2) For i = 2 To 1000 If Sheets("Staff").Cells(i, 2) = "X" Then Set rng = Union(rng, Sheets("Staff").Cells(i, 2)) End If Next i rng.Rows.EntireRow.Hidden = True End Sub (original code by Alok Joshi) Thank you, Robert |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Hide Rows meeting condition Amendment
Hi Robert,
Try: Sub Tester() Dim i As Long Dim rng As Range Dim rng2 As Range Dim SH As Worksheet Set SH = Sheets("Staff") With SH Set rng = .Cells(1, 2) Set rng2 = .Range("CondRange") For i = 2 To rng2.Rows.Count If .Cells(i, 2).Value = "X" Then Set rng = Union(rng, .Cells(i, 2)) End If Next i rng.Rows.EntireRow.Hidden = True End With End Sub '<<============== --- Regards, Norman "Robert" wrote in message ... Can some one amend the following code to substitute 2 to 10000 to a named range "CondRange" (for condition range) -- Dim i%, rng As Range Set rng = Sheets("Staff").Cells(1, 2) For i = 2 To 1000 If Sheets("Staff").Cells(i, 2) = "X" Then Set rng = Union(rng, Sheets("Staff").Cells(i, 2)) End If Next i rng.Rows.EntireRow.Hidden = True End Sub (original code by Alok Joshi) Thank you, Robert |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Hide Rows meeting condition Amendment
Thank you Norman. Using the range name is superfast. Never expected this way.
-- Robert |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Hide Rows If Condition True | Excel Worksheet Functions | |||
Is there a simple procedure to hide rows if a condition is met | Excel Discussion (Misc queries) | |||
hide rows where cell condition is not met | Excel Worksheet Functions | |||
Determine number of rows meeting a condition | Excel Discussion (Misc queries) | |||
how to create a formula to hide specific rows after meeting requi | New Users to Excel |