code takes to long

S

Scooter

Why does this code take about 4-5 minutes to excute? I does 4 replacements
for each cell.

Range("C16:BJ17").Select
Selection.Replace What:="ABC", Replacement:="XYZ", LookAt:= _
xlPart, SearchOrder:=xlByRows, MatchCase:=False,
SearchFormat:=False, _
ReplaceFormat:=False
 
N

Nigel

Try running it by not selecting the range first?

With Range("C16:BJ17")
.Replace What:="ABC", Replacement:="XYZ", LookAt:= _
xlPart, SearchOrder:=xlByRows, MatchCase:=False,
SearchFormat:=False, _
ReplaceFormat:=False
End With
 
P

Per Jessen

Hi

Try to skip the select statement:

Range("C16:BJ17").Replace What:="ABC", Replacement:="XYZ", LookAt:= _
xlPart, SearchOrder:=xlByRows, MatchCase:=False,
SearchFormat:=False, _
ReplaceFormat:=False

Regards,
Per
 
M

Mike H

Hi,

I would guess you have a lot of formula and each change is forcing a
recalculation so disable calculations and screenupdating

Application.Calculation = xlCalculationManual
Application.ScreenUpdating = False

'your code

Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True

Mike
 
E

Eric G

It runs nearly instantly for me on some made up data, and properly does the
substitution. I'm running Office 2003

Eric
 
S

Scooter

That did not seem to have any affect. With 2003 it was fast and this
started with 2007.
 
S

Scooter

That did not seem to have any affect. With 2003 it was fast and this
started with 2007.
 
S

Scooter

That did not seem to have any affect. With 2003 it was fast and this
started with 2007.
 

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