• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Does Excessive Comment Notes In Macro Code Slow Down Speed?

I have a lot of notes to keep track of what I'm doing, but I'm curious if this slowing my macros down?


Also, does empty line breaks in macro code effect the speed as well?
 
nope.. you can paste the entire work of Shakespeare in VBA comments and it wouldnt slow down the code execution... same with line breaks... Although, both will make the VBA editor slow if used in excess
 
Fantastic thanks, I've been doing some research (while also using a macro timer).


It appears the last code beneath makes everything run a lot faster.


[pre]<br />
Sub Your_macro()</p>
<p>Dim counter As Single<br />
counter = Timer</p>
<p>< Your macro code goes here></p>
<p>MsgBox "That took " & Timer - counter & " seconds."</p>
<p>End sub<br />



This is what increased my speed dramatically

</p>
<p>Sub CLEAN()</p>
<p> Application.Calculation = xlCalculationManual<br />
Application.ScreenUpdating = False<br />
Application.EnableEvents = False</p>
<p> Dim xLong As Long, csht As Long<br />
For csht = 1 To ActiveWorkbook.Worksheets.Count<br />
Worksheets(csht).Select<br />
xLong = ActiveSheet.UsedRange.Rows.Count + _<br />
ActiveSheet.UsedRange.Columns.Count<br />
Next csht<br />
Sheets(1).Select<br />
Application.EnableEvents = True<br />
Application.ScreenUpdating = True<br />
Application.Calculation = xlCalculationAutomatic</p>
<p>Application.ScreenUpdating = True<br />
Application.Calculation = xlCalculationAutomatic<br />
End Sub<br />
[/pre]
 
This will be quicker still

[pre]Sub CLEAN()
Dim xLong As Long, csht As Long

Application.Calculation = xlCalculationManual
Application.ScreenUpdating = False
Application.EnableEvents = False

With ActiveWorkbook

For csht = 1 To .Worksheets.Count

With .Worksheets(csht).UsedRange

xLong = .Rows.Count + .Columns.Count
End With
Next csht
End With

Application.EnableEvents = True
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
End Sub[/pre]

although as far as I can see, your code does absolutely nothing.
 
@ xld


It doesn't do anything? : (


Your code looks just like mine, am I missing something, or is something in the wrong place?
 
Back
Top