Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 113
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 113
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Hide Rows If Condition True wilbursj Excel Worksheet Functions 2 April 20th 09 08:09 PM
Is there a simple procedure to hide rows if a condition is met fishingengineer Excel Discussion (Misc queries) 1 April 13th 07 08:26 PM
hide rows where cell condition is not met amaries Excel Worksheet Functions 1 January 9th 07 06:50 PM
Determine number of rows meeting a condition Snapps Excel Discussion (Misc queries) 4 November 2nd 06 08:40 PM
how to create a formula to hide specific rows after meeting requi DNelson New Users to Excel 2 February 7th 06 01:06 PM


All times are GMT +1. The time now is 03:41 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"