Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 28
Default VBA Slow Peformance on Formatting

I am using Excel 97 and have been trying to use macro to do formatting on certain cells based on the value (Conditional Formatting doesn't work as I have more then 5 conditions). The program works fine but it takes way too long to do it. For example, a procedure that completes in 10 second would take 50 seconds. Anyone knows why it takes this long? And how to speed it up?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default VBA Slow Peformance on Formatting

Hi
without seeing your macro as one idea:
disable screenupdating during the macro execution. Also emove select
statements.

But you may post the relevant part of your current macro


--
Regards
Frank Kabel
Frankfurt, Germany


Anson wrote:
I am using Excel 97 and have been trying to use macro to do
formatting on certain cells based on the value (Conditional
Formatting doesn't work as I have more then 5 conditions). The
program works fine but it takes way too long to do it. For example, a
procedure that completes in 10 second would take 50 seconds. Anyone
knows why it takes this long? And how to speed it up?


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 28
Default VBA Slow Peformance on Formatting

Thanks for responding the codes are below. Initally I had:
".Borders(xlEdgeBottom).Weight = xlHairline" coded in each of the cases in Select Case but it showed down the program too much to be acceptable.


Private Sub Refresh(iStart As Integer)

Dim i As Integer
Dim Pivot As Range, rngCurrent As Range
Dim colNumber As Integer, rowNumber As Integer

ActiveSheet.Unprotect password:="anson"

'----------------------------------------------------------
'Gather Sheet Information
Set Pivot = [A12]
colNumber = Range(Pivot, Pivot.End(xlToRight)).Count
rowNumber = Range(Pivot.Offset(1, 0), Pivot.End(xlDown)).Count

'----------------------------------------------------------
'Reset Universal Formatting
With Range(Pivot.Offset(1, 0), Pivot.Offset(rowNumber, colNumber - 1))
.Borders(xlEdgeBottom).Weight = xlHairline
.Borders(xlInsideHorizontal).Weight = xlHairline
.Font.Name = "MS Sans Serif"
.Font.ColorIndex = xlAutomatic
End With

'Reset Individual Formatting
For i = 1 To colNumber
Select Case Pivot.Offset(0, i - 1).Value

Case "Confirm Merit Eligibility (Yes/No)"
Range(Pivot.Offset(1, i - 1), Pivot.Offset(rowNumber, i - 1)). _
Interior.ColorIndex = 35

Case "New Perf. Rating"
With Range(Pivot.Offset(1, i - 1), Pivot.Offset(rowNumber, i - 1))
.Interior.ColorIndex = 35

.Validation.Delete
.Validation.Add Type:=xlValidateList, _
AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:="Exceeds,Meets,Below"
.Validation.IgnoreBlank = True
.Validation.InCellDropdown = True
.Validation.ShowInput = True
.Validation.ShowError = True
End With

Case "Comments"
Range(Pivot.Offset(1, i - 1), Pivot.Offset(rowNumber, i - 1)). _
Interior.ColorIndex = 35

Case "% Salary Increase"
Range(Pivot.Offset(1, i - 1), Pivot.Offset(rowNumber, i - 1)). _
Interior.ColorIndex = 35

Case "$ Salary Increase"
Range(Pivot.Offset(1, i - 1), Pivot.Offset(rowNumber, i - 1)). _
Interior.ColorIndex = 35

Case "% Merit Bonus"
Range(Pivot.Offset(1, i - 1), Pivot.Offset(rowNumber, i - 1)). _
Interior.ColorIndex = 35

Case "$ Merit Bonus"
Range(Pivot.Offset(1, i - 1), Pivot.Offset(rowNumber, i - 1)). _
Interior.ColorIndex = 35

Case "Optional Field"
Range(Pivot.Offset(1, i - 1), Pivot.Offset(rowNumber, i - 1)). _
Interior.ColorIndex = 35

End Select
Next i

ActiveSheet.Protect password:="anson"


End Sub


"Frank Kabel" wrote:

Hi
without seeing your macro as one idea:
disable screenupdating during the macro execution. Also emove select
statements.

But you may post the relevant part of your current macro


--
Regards
Frank Kabel
Frankfurt, Germany


Anson wrote:
I am using Excel 97 and have been trying to use macro to do
formatting on certain cells based on the value (Conditional
Formatting doesn't work as I have more then 5 conditions). The
program works fine but it takes way too long to do it. For example, a
procedure that completes in 10 second would take 50 seconds. Anyone
knows why it takes this long? And how to speed it up?



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
Excel2007 Conditional Formatting Slow Performance Issue Michael F Excel Worksheet Functions 1 June 26th 09 05:42 PM
VERY SLOW Yousoft Excel Discussion (Misc queries) 1 December 11th 07 12:56 PM
Slow Excel Navigation with Up / Down Arrow and slow scrolling deddog Excel Discussion (Misc queries) 0 August 14th 07 09:56 PM
MS Excel is too slow when formatting, setuping page, etc. Malvin Excel Discussion (Misc queries) 1 February 6th 06 03:00 PM
How can I improve the snail-pace peformance of Excel 2003? J.K. August Excel Discussion (Misc queries) 1 June 30th 05 11:58 PM


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

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"