LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
Jay Jay is offline
external usenet poster
 
Posts: 671
Default Cell formatting -- why so slow?

Please take a look at the loop I'm running below...this is taking forever to
execute. It looks pretty simple to me and I'm not sure what the hold up is.
If I cycle through the code in debug mode, every "end with" takes some time,
I assume because the formatting is taking so much time. Does anyone know why
these formatting commands are taking so long to execute?

ws is a worksheet object.
colL colM and colN are collection objects with information pulled from a
table in another application.

For I = 1 To colM.Count
ws.Cells(((I - 1) * 4) + nStartRow, 1) = colL.Item(I)
With ws.Range(Cells(((I - 1) * 4) + nStartRow, 1), Cells(((I - 1) * 4) +
nStartRow + 2, 1))
.Merge
.WrapText = True
.VerticalAlignment = xlTop
End With

With ws.Cells(((I - 1) * 4) + nStartRow, 2)
.Value = colS.Item(I)
.Cells.NumberFormat = "0.0000"
.Cells.HorizontalAlignment = xlCenter
End With

With ws.Cells(((I - 1) * 4) + nStartRow, 3)
.Value = colE.Item(I)
.Cells.NumberFormat = "0.0000"
.Cells.HorizontalAlignment = xlCenter
End With

With ws.Cells(((I - 1) * 4) + nStartRow, 4)
.Value = colM.Item(I)(nSegs)
.Cells.NumberFormat = "0.00"
.Cells.HorizontalAlignment = xlCenter
End With

With ws.Cells(((I - 1) * 4) + nStartRow + 1, 4)
.Value = colN.Item(I)(nSegs)
.Cells.NumberFormat = "0"
.Cells.HorizontalAlignment = xlCenter
End With

For J = 1 To nSegs - 1
With ws.Cells(((I - 1) * 4) + nStartRow, J + 4)
.Value = colM.Item(I)(J)
.Cells.NumberFormat = "0.00"
.Cells.HorizontalAlignment = xlCenter
End With

With ws.Cells(((I - 1) * 4) + nStartRow + 1, J + 4)
.Value = colN.Item(I)(J)
.Cells.NumberFormat = "0"
.Cells.HorizontalAlignment = xlCenter
End With

With ws.Cells(((I - 1) * 4) + nStartRow + 2, J + 4)
.Value = colLMH(I)(J)
.Cells.HorizontalAlignment = xlCenter
End With
Next J

'shrink every fourth row
ws.Cells(((I - 1) * 4) + nStartRow + 3, 1).RowHeight = 6
Next I
 
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
Excel2007 Conditional Formatting Slow Performance Issue Michael F Excel Worksheet Functions 1 June 26th 09 05:42 PM
Slow Excel Navigation with Up / Down Arrow and slow scrolling deddog Excel Discussion (Misc queries) 0 August 14th 07 09:56 PM
VBA Page Setup/Formatting EXTREMELY Slow... Help! MikeZz Excel Programming 5 March 16th 07 12:56 PM
MS Excel is too slow when formatting, setuping page, etc. Malvin Excel Discussion (Misc queries) 1 February 6th 06 03:00 PM
VBA Slow Peformance on Formatting Anson[_2_] Excel Programming 2 June 10th 04 07:07 PM


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