Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 246
Default Slow Function

I've tried the below function over a range of 6000 cells.

'======================================
Private Function TrimAll(myTrimArea As Range)
Dim cell
For Each cell In myTrimArea.Cells
cell.Value = Trim(cell.Value)
Next cell
End Function
'======================================

.....it's very slow.
What is wrong with my code ?

Any help greatly appreciated
J

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 772
Default Slow Function

This should help considerably, it turns off all processing, does the work,
and then calculates once instead of thousands of times.

Private Function TrimAll(myTrimArea As Range)
Dim cell
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual

For Each cell In myTrimArea.Cells
cell.Value = Trim(cell.Value)
Next cell
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic

End Function


--
-John
Please rate when your question is answered to help us and others know what
is helpful.


"WhytheQ" wrote:

I've tried the below function over a range of 6000 cells.

'======================================
Private Function TrimAll(myTrimArea As Range)
Dim cell
For Each cell In myTrimArea.Cells
cell.Value = Trim(cell.Value)
Next cell
End Function
'======================================

.....it's very slow.
What is wrong with my code ?

Any help greatly appreciated
J


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
Re-calculate function too slow CB Excel Discussion (Misc queries) 1 November 27th 07 02:39 PM
slow replace function hiwan99 Excel Worksheet Functions 3 July 6th 05 11:49 PM
Slow Function Nigel Bennett Excel Programming 1 May 7th 05 11:16 PM
macro function is too slow! Tommy Brown Excel Programming 4 April 22nd 04 07:54 PM
Optimize Slow function Kent Schederin Excel Programming 3 February 17th 04 05:56 PM


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