Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 43
Default code takes to long

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 735
Default code takes to long

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

--

Regards,
Nigel




"Scooter" wrote in message
...
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


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,533
Default code takes to long

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

"Scooter" skrev i meddelelsen
...
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


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default code takes to long

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

"Scooter" wrote:

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

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default code takes to long

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

Eric

"Scooter" wrote:

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



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 43
Default code takes to long

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

"Per Jessen" wrote:

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

"Scooter" skrev i meddelelsen
...
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



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 43
Default code takes to long

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

"Mike H" wrote:

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

"Scooter" wrote:

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

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 43
Default code takes to long

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

"Nigel" wrote:

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

--

Regards,
Nigel




"Scooter" wrote in message
...
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



  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 43
Default code takes to long

With 2003 it was fast and this started with 2007.

"Eric G" wrote:

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

Eric

"Scooter" wrote:

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

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
Code takes a long time to process Sandy Excel Programming 1 June 19th 08 08:08 PM
Code takes to long Oggy Excel Discussion (Misc queries) 1 March 30th 08 10:56 PM
Clearing cells takes long, long time unclemuffin Excel Discussion (Misc queries) 9 August 17th 07 02:22 AM
execution of code takes very long Ritesh S. Excel Programming 1 September 17th 04 07:26 PM
Clock how long it takes code to run? Steph[_3_] Excel Programming 3 June 2nd 04 09:34 PM


All times are GMT +1. The time now is 03:49 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"