Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default EntireRow.Hidden

Hi!

Why doesn't Sub ERROR work (se below)? I use the same
syntax.

What I really want to do is to find the fastest way of
hide rows in a column that meets a condition. The ultimate
would be to hide every row in one operation instead of
using a loop.

Sub OK()
Do While lRow < lEndRow
If Cells(lRow, 1) < "Red" Then
Rows(lRow).EntireRow.Hidden = True
End If
lRow = lRow + 1
Loop
End Sub

Sub ERROR()
For Each c In [A1:A1000]
If c.Value Like "Red" Then
Rows(c.Row).EntireRow.Hidden = True
End If
Next
End Sub

/jonas
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 493
Default EntireRow.Hidden

Your Sub ERROR works for me...

Here's one way to hide all the rows at once:

Public Sub HideRed()
Dim c As Range
Dim hideRange As Range
For Each c In Range("A1:A" & _
Range("A" & Rows.Count).End(xlUp).Row)
If c.Value = "Red" Then
If hideRange Is Nothing Then
Set hideRange = c
Else
Set hideRange = Union(hideRange, c)
End If
End If
Next c
If Not hideRange Is Nothing Then _
hideRange.EntireRow.Hidden = True
End Sub





In article ,
"Jonas Haettner" wrote:

Hi!

Why doesn't Sub ERROR work (se below)? I use the same
syntax.

What I really want to do is to find the fastest way of
hide rows in a column that meets a condition. The ultimate
would be to hide every row in one operation instead of
using a loop.

Sub OK()
Do While lRow < lEndRow
If Cells(lRow, 1) < "Red" Then
Rows(lRow).EntireRow.Hidden = True
End If
lRow = lRow + 1
Loop
End Sub

Sub ERROR()
For Each c In [A1:A1000]
If c.Value Like "Red" Then
Rows(c.Row).EntireRow.Hidden = True
End If
Next
End Sub

/jonas

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
MACRO: Selecting "Cancel" from a drop down to copy and paste entirerow to another sheet Nicole Hannington Excel Worksheet Functions 1 July 20th 09 06:51 PM
Need Help with ActiveCell.EntireRow.Delete Ayo Excel Discussion (Misc queries) 4 July 20th 08 11:07 AM
Need Help with ActiveCell.EntireRow.Delete Ayo Excel Discussion (Misc queries) 8 July 19th 08 04:45 PM
ListBox1. add item myCell.entirerow Vikram Dhemare Excel Discussion (Misc queries) 3 April 8th 08 01:49 AM
delete entirerow if date more than 12months old flow23 Excel Discussion (Misc queries) 1 May 25th 06 03:32 PM


All times are GMT +1. The time now is 04:51 AM.

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

About Us

"It's about Microsoft Excel"