Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
ski ski is offline
external usenet poster
 
Posts: 3
Default Can anyone help me figure this out?

I have a sub that hides recorders that are younger than a specified
date as long as they aren't part of a group that has a record in it
which is older than that date.
The sub works except the time that it takes increases exponentially to
the number of records that need to be hidden.
When that number gets upwards of 2000 out of 6000 it can take 10's of
mins, which kills its usefulness.
The problem seems to be in changing the hidden property to true. For
some reason this process takes an excessive amount of time.
I was thinking I may be able to collect the rows into an object or
range and hide them all at once but I haven't been able to come up
with a way to do that cleanly. (ie: select a row, find the next row
and it to the selection …)
Can anyone help me find a way to speed this up?
I'll be your best friend :)

Shaun Kohanowski
general macro nerd @ SEI

Sub Age_Select()

'This is error handling
On Error Resume Next
If Not Cells(1, ZONE).Value = "Zone" Then
End
End If
On Error GoTo 0

'This is preprocess setup
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual

Dim age As Integer
Cells.EntireRow.Hidden = False

'This converts the string contents of the combo box to a day value
Set neoControl = Application.CommandBars("Open
Cases").FindControl(msoControlComboBox)
Select Case neoControl.List(neoControl.ListIndex)
Case "Day"
age = 1
Case "3 Days"
age = 3
Case "Week"
age = 7
Case "2 Weeks"
age = 14
Case "Month"
age = 30
End Select

'This locates and hides the records that are younger than the day
value
'and are not of the same group ID
i = 2
j = 2
Do Until Cells(i, LAST) = ""
If DateDiff("d", Cells(i, LAST), Now()) <= age Then
If Not Cells(i, NATL) = Cells(j, NATL) Then
Rows(i).Hidden = True ' <--- This seems to be the
problem
End If
j = i
End If
i = i + 1
Loop

'This is post processing cleanup
Group

Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Can anyone help me figure this out?

Hi Shaun,

the following type of construct should do want you want:

Dim Rng As Range

If Not Rng Is Nothing Then
Set Rng = Union(Rng, Rows(i))
Else
Set Rng = Rows(i)
End If
Next
Rng.EntireRow.Hidden = True


In terms of speed. it might be worth adding the line:

ActiveSheet.DisplayPageBreaks = False


---
Regards,
Norman



"ski" wrote in message
om...
I have a sub that hides recorders that are younger than a specified
date as long as they aren't part of a group that has a record in it
which is older than that date.
The sub works except the time that it takes increases exponentially to
the number of records that need to be hidden.
When that number gets upwards of 2000 out of 6000 it can take 10's of
mins, which kills its usefulness.
The problem seems to be in changing the hidden property to true. For
some reason this process takes an excessive amount of time.
I was thinking I may be able to collect the rows into an object or
range and hide them all at once but I haven't been able to come up
with a way to do that cleanly. (ie: select a row, find the next row
and it to the selection .)
Can anyone help me find a way to speed this up?
I'll be your best friend :)

Shaun Kohanowski
general macro nerd @ SEI

Sub Age_Select()

'This is error handling
On Error Resume Next
If Not Cells(1, ZONE).Value = "Zone" Then
End
End If
On Error GoTo 0

'This is preprocess setup
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual

Dim age As Integer
Cells.EntireRow.Hidden = False

'This converts the string contents of the combo box to a day value
Set neoControl = Application.CommandBars("Open
Cases").FindControl(msoControlComboBox)
Select Case neoControl.List(neoControl.ListIndex)
Case "Day"
age = 1
Case "3 Days"
age = 3
Case "Week"
age = 7
Case "2 Weeks"
age = 14
Case "Month"
age = 30
End Select

'This locates and hides the records that are younger than the day
value
'and are not of the same group ID
i = 2
j = 2
Do Until Cells(i, LAST) = ""
If DateDiff("d", Cells(i, LAST), Now()) <= age Then
If Not Cells(i, NATL) = Cells(j, NATL) Then
Rows(i).Hidden = True ' <--- This seems to be the
problem
End If
j = i
End If
i = i + 1
Loop

'This is post processing cleanup
Group

Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
End Sub



  #3   Report Post  
Posted to microsoft.public.excel.programming
ski ski is offline
external usenet poster
 
Posts: 3
Default Can anyone help me figure this out? The Magic Man Can

Norman,
You are a super magical man :)
That cut the run time to less than half a min
Wish I knew why
This is what I ended up with
thanks again

Shaun


Dim hideList As Range
Set hideList = Rows(Rows.Count)

i = 2
j = 2
Do Until Cells(i, LAST) = ""
If DateDiff("d", Cells(i, LAST), Now()) <= age Then
If Not Cells(i, NATL) = Cells(j, NATL) Then
Set hideList = Union(hideList, Rows(i))

End If
Else
j = i
End If
i = i + 1
Loop
hideList.EntireRow.Hidden = True
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 863
Default Can anyone help me figure this out? The Magic Man Can

If the change was to hide all rows at the end, instead of one at a time,
that's the reason: operations like that are very time-consuming, and it takes
very little more time to carry it out on several rows than on one.

On 6 Oct 2004 15:14:43 -0700, (ski) wrote:

Norman,
You are a super magical man :)
That cut the run time to less than half a min
Wish I knew why
This is what I ended up with
thanks again

Shaun


Dim hideList As Range
Set hideList = Rows(Rows.Count)

i = 2
j = 2
Do Until Cells(i, LAST) = ""
If DateDiff("d", Cells(i, LAST), Now()) <= age Then
If Not Cells(i, NATL) = Cells(j, NATL) Then
Set hideList = Union(hideList, Rows(i))

End If
Else
j = i
End If
i = i + 1
Loop
hideList.EntireRow.Hidden = True


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
HOW TO 'BLINK' A FIGURE INSTEAD OFF BOLDING THE FIGURE Nad.Engoor Excel Worksheet Functions 3 December 30th 08 03:04 PM
Can't figure this out SGT Buckeye Excel Discussion (Misc queries) 1 June 5th 08 03:08 AM
Can't figure this out!!! Tilleyswife Excel Worksheet Functions 3 November 9th 06 06:21 PM
Can't figure it out . . . [email protected] Excel Worksheet Functions 8 May 3rd 06 04:29 AM
Can't figure it out bat_big Excel Programming 1 September 3rd 04 03:54 AM


All times are GMT +1. The time now is 10:59 PM.

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"