Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Lock up with Arrays

I have a spreadsheet with a list of strings on the first tab and a list of
search and replace strings on the second tab. I'm writing both to arrays
(searchArray and replaceArray) and then looping through them to do some
complicated search and replace functions. The following code usually runs
fine. However once I get up to around 10,000 strings to search and 1000
search and replace strings, Excel is locking up in the middle of the
function. I'm wondering if there's some upper limit on the amount of data I
can process in arrays and how I could get around this.

'initialize variable to record the number of search/replaces that are made
NoCorrections = 0

'iterate through the searchArray and search/replace with the strings in
replaceArray
For i = 1 To UBound(searchArray, 1)
For j = 1 To UBound(searchArray, 2)
For k = 2 To UBound(replaceArray, 1)

'only allow search/replace loop if search/replace terms are
not identical
'to prevent infinite looping

If Trim(LCase(replaceArray(k, iSearch))) <
Trim(LCase(replaceArray(k, iReplace))) Then
'keep looping through until ALL occurrences of search string
in search text have been replaced
Do Until InStr(LCase(searchArray(i, j)),
LCase(replaceArray(k, iSearch))) = 0
NoCorrections = NoCorrections + 1
'replace search string with replace string
searchArray(i, j) = Replace(searchArray(i, j),
replaceArray(k, iSearch), replaceArray(k, iReplace), 1, -1, vbTextCompare)
Loop
End If
Next
Next
Next

'write search/replaced searchArray back to worksheet
Range(searchRangeStr) = searchArray

'return no. of corrections made
SearchReplaceArrays = NoCorrections


Thanks,
Wayne Cressman


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 do I turn scroll lock off (2007 excel)? No scroll lock key Cameron A Perth Excel Discussion (Misc queries) 1 September 18th 09 05:46 AM
How to lock the Ctrl key? (as locking the Shift key w/Caps Lock) Rick-cel Excel Discussion (Misc queries) 2 August 5th 09 06:45 PM
how do I undo the scroll lock, thscroll lock button does not work scroll lock Excel Discussion (Misc queries) 3 July 19th 08 10:17 PM
I have lock a wookbook but one cell does not want to lock it Mimi Excel Discussion (Misc queries) 2 January 21st 07 10:59 PM
I have lock a wookbook but one cell does not want to lock it Mimi Excel Discussion (Misc queries) 1 January 21st 07 09:44 AM


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