|
|
Post some code - it may just be the way your loop is constructed that's slowing things down.
Eric
I read your other post. In case you didn't get an answer, you can actually get microsecond timing in VBA. Use the code below.
I had a similar problem to yours, only it was in PowerPoint when I was building slides in VBA. The more slides I built, the slower the code went - dramatically slower. The theory (not proven) there was that the undo stack in PowerPoint was getting unmanageably huge and every time you added an object to it it would take longer to increase the stack size. Or something like that.
Eric
'=========== CODE START ==============
Option Explicit
#If VBA7 Then
Private Declare PtrSafe Function getFrequency Lib "kernel32" Alias "QueryPerformanceFrequency" (cyFrequency As Currency) As Long
Private Declare PtrSafe Function getTickCount Lib "kernel32" Alias "QueryPerformanceCounter" (cyTickCount As Currency) As Long
#Else
Private Declare Function getFrequency Lib "kernel32" Alias _
"QueryPerformanceFrequency" (cyFrequency As Currency) As Long
Private Declare Function getTickCount Lib "kernel32" Alias _
"QueryPerformanceCounter" (cyTickCount As Currency) As Long
#End If
'
' This function returns the value of the Windows high resolution
' (microsecond) timer, in seconds.
'
Public Function MicroTimer() As Double
'
' returns seconds
' uses Windows API calls to the high resolution timer
'
Dim cyTicks1 As Currency
Dim cyTicks2 As Currency
Static cyFrequency As Currency
'
MicroTimer = 0
'
' get frequency
'
If cyFrequency = 0 Then getFrequency cyFrequency
'
' get ticks
'
getTickCount cyTicks1
getTickCount cyTicks2
If cyTicks2 < cyTicks1 Then cyTicks2 = cyTicks1
'
' calc seconds
'
If cyFrequency Then MicroTimer = cyTicks2 / cyFrequency
End Function
'=========== CODE END ===============
More research shows that the time taken by .TEXT is a function of the number of rows between the rows visible in the sheet window and the row you are getting .TEXT from.
This effect only seems to happen if the row-height of some of the rows has been changed.
So one bypass is to set Screenupdating to True and select the cell before getting the text value.
(In general using .TEXT is a bad idea because it gets the formatted value and the user may have done something that will make .TEXT return ### etc. Its better to use .VALUE2 instead)
More research shows that the time taken by .TEXT is a function of the number of rows between the rows visible in the sheet window and the row you are getting .TEXT from.
I need to use .Text precisely because the user may have entered custom formatting and I can't rely on them being sophisticated enough to know that the VALUE is different from what's shown in the cell, so users didn't understand why they shouldn't use formatting instead of actually properly formatting the data themselves, so I have to accommodate that.As a matter of curiosity why are you trying to compare the CGID .Text with .Value to detect duplicates? This seems like comparing apples and oranges to me ...
Enter the thread ID of the thread you are merging into
To report abuse, sign in or continue without signing in
Thank you.
|
|
|
|
Don't have one of the above accounts?