LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default how to speed Find/Replace in Excel(Using VB)

when I use VBA in Excel. I find it does't speed the operation.
with more and more tags that will be replaced, the operation is slower and
slower.
it cost more than 5s if 22 tags will be replaced
how can I do?

my code(Using VBA):
Sub Macro1()
Dim tags As ArrayList
Dim i As Integer
Dim j As Integer
Set tagsfs = New FileSys
'in tags.txt,tagname and value put in it,for example
'tag1=value1
'tag2=value2
tagsfs.setFilePath "d:\tags.txt"
Application.DisplayAlerts = False
Set tags = tagsfs.getAllLines
For i = 1 To Sheets.Count
Sheets(i).Activate
For j = 0 To tags.Length - 1
'tags.getValue(index): tagname=value
contents = Split(tags.getValue(j), "=", 2)
Set findRange = Cells.Find(what:=contents(0))
While Not findRange Is Nothing
findRange.Activate
'if tags is #LT_CHART#, add one picture
If InStr(1, contents(0), "#LT_CHART#") 0 Then
ActiveSheet.Pictures.Insert( _
contents(1)).Select
Cells.Replace what:="#LT_CHART#", Replacement:=""
Else
Cells.Replace what:=contents(0), Replacement:=contents(1)
End If
Set findRange = Cells.FindNext(After:=ActiveCell)
Wend
Next j
Next i
End Sub


 
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
Speed of Replace Range Monk[_2_] Excel Discussion (Misc queries) 6 May 24th 08 04:57 AM
Find and replace in excel ChrisB Excel Discussion (Misc queries) 4 January 17th 07 08:34 PM
find and replace - replace data in rows to separated by commas msdker Excel Worksheet Functions 1 April 15th 06 01:00 AM
Optimizing a macro for speed- find and replace trickdos[_20_] Excel Programming 2 November 12th 04 10:21 PM
Optimizing a macro for speed- find and replace trickdos[_19_] Excel Programming 3 November 12th 04 12:41 AM


All times are GMT +1. The time now is 12:21 AM.

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"