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: 25
Default Slow code.... Any thoughts on how to speed it up?

I have written some code to walk through a spreadsheet, compare 1 cell value
to the following row, if it is the same, then to compare a second cell
value, see if it is included in a teststring, if not to add that value to a
teststring, and then continue looping - testing the first value. When that
is done, to go to the first instance of the fist value, replace a cell in
each occurance of that value, and then go to the next record. (I hope that
was not TOO confusing....)
WS is sorted by firstvalue and then by the second value. I am using EXCEL
2007. The statusbar is just for testing so I can see what is going on. I can
be removed.

Below is the code I have written. Is there a better way to do this? based on
the display of the statusbar, it seems to be very slow during the "FILLING"
loop.

Sub stepthrough()
Dim iRecCount, sString, iCnt

iRecCount = LastRow(Worksheets("Sheet1")) - 1
sString = ""
'temp = MsgBox(iRecCount)
iCnt = 2
tester1 = Worksheets("Sheet1").Cells(iCnt, 93).Value
' P = MsgBox(tester1)

Do
tester1 = Worksheets("Sheet1").Cells(iCnt, 93).Value

counter = 0
' Loop while KEY (Col 93) remains the same
Do While Worksheets("Sheet1").Cells(iCnt + counter, 93).Value = tester1
'If Catagories is not found in the existing sString, then add it.
(need to later on parse
'each item in the active catagory
If
Application.IsError(Application.Find(Worksheets("S heet1").Cells(iCnt +
counter, 55).Value, sString)) Then
sString = sString & "; " & Worksheets("Sheet1").Cells(iCnt +
counter, 55).Value
End If
Application.StatusBar = CStr(iCnt) & " of " & CStr(iRecCount) & " |
building CAT:for " & " " & counter & " | "
' & tester1

counter = counter + 1 'count how many records have the KEY
Loop

counter = 0

' again, loop through the same records, and then set need column to the
new catigory list
Do While Worksheets("Sheet1").Cells(iCnt + counter, 93).Value = tester1
Worksheets("Sheet1").Cells(iCnt + counter, 103).Value = sString
counter = counter + 1
Application.StatusBar = CStr(iCnt) & " of " & CStr(iRecCount)
& " | FILLING CAT:for " & " " & counter & " | "
'& tester1

Loop

iCnt = iCnt + counter

sString = ""

tester1 = ""

Worksheets("Sheet1").Cells(iCnt, 106).Value = sString

'iCnt = iCnt + 1
Application.StatusBar = CStr(iCnt) & " of " & CStr(iRecCount) & " | "


Loop Until iCnt iRecCount


 
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
Slow speed Excel with Centrino duo jmb. Excel Discussion (Misc queries) 3 September 11th 06 12:35 PM
slow Macro speed Lam Chop Excel Programming 0 June 5th 06 04:00 AM
Any thoughts - VBA Slow Down with Range.Clear Command Paul Fenton Excel Programming 5 February 17th 06 02:16 PM
Speed up and slow down, the auto-scroll. Jack Tripper Excel Discussion (Misc queries) 0 September 11th 05 03:54 PM
Extremely Slow VBA Execution Speed Joe Adams[_3_] Excel Programming 3 May 15th 04 01:23 AM


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