Optimizing a macro for speed- find and replace

T

trickdos

Hey all, Thanks for your help.

I have a workbook with 2 sheets with 24,000 rows and 10 columns o
data, and I need to do a find and replace for all "#Missing" values an
return an empty cell. This takes forever. Is there anyway to optimiz
the macro to run much faster?



Application.ScreenUpdating = False

With Application
.Calculation = xlManual
End With

Sheets("Version 1").Select
Cells.Replace What:=" ", Replacement:="", LookAt:=xlPart, _
SearchOrder:=xlByColumns

ActiveWorkbook.PrecisionAsDisplayed = False
With Application
.Calculation = xlAutomatic
.MaxChange = 0.001
End With
ActiveWorkbook.PrecisionAsDisplayed = False
Application.ScreenUpdating = Tru
 
P

PaulD

What speed is your computer? I tried the following code on a sample
workbook that I filled in 24,000 rows of data and 10 columns and randomly
blanked out some of the cells

Public Sub deBlank()
Application.ScreenUpdating = False
Application.EnableEvents = False

Cells.Replace What:=" ", Replacement:="", LookAt:=xlPart, _
SearchOrder:=xlByColumns

Application.EnableEvents = True
Application.ScreenUpdating = True

End Sub

This took about 2 seconds to complete. Is there something else going on you
are not telling us? Are there calculations occuring that are taking
additional time?
Paul D
 
K

keepITcool

Maybe OP has Iteration ON...
(as he's setting the MaxChange...)

See tools/options/Calculation...

DEACTIVATE the iteration checkbox..

(which is ONLY usefull for certain specific recursive or circular
calculation scenarios)





--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


PaulD wrote :
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top