Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default this macro is slowing down my spreadsheet

I have an auto_open macro that executes several other macros, but it appears
to take a long time to finish these steps. When is ESC the process to see
where it stopped executing... is on the last "Next" statement in the
following macro:

Sub trimcells()
Sheets("manifest").Rows("5:250").Select
Dim cell As Range
On Error Resume Next 'In case no cells in selection
For Each cell In Intersect(Selection, _
Selection.SpecialCells(xlConstants, xlTextValues))
cell.Value = Trim(cell.Value)
Next
End Sub

Is this macro a loop or can it be shortened? Did i do something wrong?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 142
Default this macro is slowing down my spreadsheet

Well, yes... It's a loop. you could try to turn off screen
updating...
Application.ScreenUpdating = False
just make sure to turn it back on again after the macro is finished.
Application.ScreenUpdating = True

On Jan 24, 10:07 pm, guillermo.ht
wrote:
I have an auto_open macro that executes several other macros, but it appears
to take a long time to finish these steps. When is ESC the process to see
where it stopped executing... is on the last "Next" statement in the
following macro:

Sub trimcells()
Sheets("manifest").Rows("5:250").Select
Dim cell As Range
On Error Resume Next 'In case no cells in selection
For Each cell In Intersect(Selection, _
Selection.SpecialCells(xlConstants, xlTextValues))
cell.Value = Trim(cell.Value)
Next
End Sub

Is this macro a loop or can it be shortened? Did i do something wrong?


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default this macro is slowing down my spreadsheet

Not sure if it is faster, but is this what you want:

Dim cell As Range
For Each cell In
Worksheets("manifest").Rows("5:250").SpecialCells( xlConstants, xlTextValues)
cell.Value = Trim(cell.Value)
Next

NickHK

"guillermo.ht" wrote in message
...
I have an auto_open macro that executes several other macros, but it

appears
to take a long time to finish these steps. When is ESC the process to see
where it stopped executing... is on the last "Next" statement in the
following macro:

Sub trimcells()
Sheets("manifest").Rows("5:250").Select
Dim cell As Range
On Error Resume Next 'In case no cells in selection
For Each cell In Intersect(Selection, _
Selection.SpecialCells(xlConstants, xlTextValues))
cell.Value = Trim(cell.Value)
Next
End Sub

Is this macro a loop or can it be shortened? Did i do something wrong?



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 694
Default this macro is slowing down my spreadsheet

Hi

It may also be faster to try this instead of selecting them specificly and
adding okrob's suggestion:


Sub trimcellsnew()
Dim cell As Range

Application.ScreenUpdating=False

On Error Resume Next 'In case no cells in selection

For Each cell In _
Sheets("sheet1").Rows("5:250").SpecialCells( _
xlConstants, xlTextValues)
cell.Value = Trim(cell.Value)
Next
Application.ScreenUpdating=true
End Sub

--
Hope this helps
Martin Fishlock, Bangkok, Thailand
Please do not forget to rate this reply.


"okrob" wrote:

Well, yes... It's a loop. you could try to turn off screen
updating...
Application.ScreenUpdating = False
just make sure to turn it back on again after the macro is finished.
Application.ScreenUpdating = True

On Jan 24, 10:07 pm, guillermo.ht
wrote:
I have an auto_open macro that executes several other macros, but it appears
to take a long time to finish these steps. When is ESC the process to see
where it stopped executing... is on the last "Next" statement in the
following macro:

Sub trimcells()
Sheets("manifest").Rows("5:250").Select
Dim cell As Range
On Error Resume Next 'In case no cells in selection
For Each cell In Intersect(Selection, _
Selection.SpecialCells(xlConstants, xlTextValues))
cell.Value = Trim(cell.Value)
Next
End Sub

Is this macro a loop or can it be shortened? Did i do something wrong?



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
Slowing Down a Macro tedd13 Excel Programming 1 June 1st 06 09:11 PM
Slowing Down a Macro Jim Thomlinson Excel Programming 0 June 1st 06 08:31 PM
Macro and slowing a progress bar. Rockee052[_18_] Excel Programming 3 January 26th 04 09:34 PM
Macro slowing down after a while... SpeeD72 Excel Programming 3 October 25th 03 08:56 PM
Slowing Macro Dick Kusleika Excel Programming 1 July 29th 03 07:01 PM


All times are GMT +1. The time now is 07:43 AM.

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"