LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default More Efficient code than this

Here is a piece of code I'm using to hide rows that have an "x" in two of the
columns. Is there a more efficient way to write this.

thanks

Sub HideRows()
Application.ScreenUpdating = False

Dim rng As Range
Dim i As Long

Set rng = Range("E5:E204")
i = 0 'set up a variable to see if range contains hidden rows

For Each c In rng
If c.EntireRow.Hidden = True Then
c.EntireRow.Hidden = False
i = 1
End If
Next

If i = 1 Then 'if any hidden rows unhide
Application.ScreenUpdating = True
Exit Sub
End If

For Each c In rng 'if no hidden rows unhidden then hide
If c.Value = "x" And c.Offset(0, 3).Value = "x" Then
c.EntireRow.Hidden = True
End If
Next
Application.ScreenUpdating = True
End Sub


 
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
making code more efficient timmulla Excel Discussion (Misc queries) 3 January 23rd 07 02:16 PM
Which is more efficient? Norm[_5_] Excel Programming 3 April 2nd 04 04:24 PM
Making code more efficient Tommi[_2_] Excel Programming 8 December 13th 03 07:47 PM
Book on how to write VBA code in a fast/efficient manner? J S Excel Programming 3 November 26th 03 02:12 PM
More efficient code Rob Bovey Excel Programming 1 July 9th 03 04:46 AM


All times are GMT +1. The time now is 03:09 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"