View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Stu[_31_] Stu[_31_] is offline
external usenet poster
 
Posts: 27
Default Another Speed Problem!

I did not know that Year is a VB or XL keyword or function. I have just
named my macros as to what they do.

Thanks
--
Stu
"J.E. McGimpsey" wrote in message
...
One way:

Public Sub YearHide()
Dim hideRange As Range
For Each rng In Range("B3:B21,B28:B45,B52:B69," & _
"B76:B93,B100:B117,B124:B141,B148:B165," & _
"B172:B189,B196:B213,B220:B237,B244:B261,B268:B285 ")
If rng.Value = "" Then
If hideRange Is Nothing Then
Set hideRange = rng.Offset(1, 0)
Else
Set hideRange = Union(hideRange, rng.Offset(1, 0))
End If
End If
Next rng
If Not hideRange Is Nothing Then _
hideRange.EntireRow.Hidden = True
End Sub

Note that it's better to use macro names that are neither VBA nor XL
keywords or function names - cuts down on confusion.

In article ,
"Stu" wrote:

Hey guys, I have some more code that takes its time being ran, any ideas

on
how to speed it up?

Here's the code:

Sub Year()

Dim Rng As Range
For Each Rng In

Range("B3:B21,B28:B45,B52:B69,B76:B93,B100:B117,B1 24:B141,B148:B165,B172:B18
9,B196:B213,B220:B237,B244:B261,B268:B285")
Rng(2, 1).EntireRow.Hidden = (Rng.Value = "")
Next Rng

End Sub

Thanks
---
Stu