Most of the times VBA Developer encounter this issue that there VBA code is taking lot of time to execute, hence i am posting some of the tips that will help VBA code to run faster.
1)Always make Screen Updating Value to false before running the program, it will save lot of time.
To prove this lets write a simple program without turn off screen updating values and with turn off screen update values.
Condition1 :When Screen Updating is not mentioned by default its true.
Public Function TestVBACode()
Program_Start_Time = Timer
For i = 1 To 10
Range("A" & i).value = "Hello VBA"
Next i
MsgBox Program_Start_Time - Start & "Seconds"
End Function
Condition2:When Screen Updating is mentioned as false.
Public Function TestVBACode()
Application.ScreenUpdating = False
Program_Start_Time = Timer
For i = 1 To 10
Range("A" & i).value = "Hello VBA"
Next i
Application.Screen Updating = True
MsgBox Program_Start_Time - Start & "Seconds"
End Function
1)Always make Screen Updating Value to false before running the program, it will save lot of time.
To prove this lets write a simple program without turn off screen updating values and with turn off screen update values.
Condition1 :When Screen Updating is not mentioned by default its true.
Public Function TestVBACode()
Program_Start_Time = Timer
For i = 1 To 10
Range("A" & i).value = "Hello VBA"
Next i
MsgBox Program_Start_Time - Start & "Seconds"
End Function
Condition2:When Screen Updating is mentioned as false.
Public Function TestVBACode()
Application.ScreenUpdating = False
Program_Start_Time = Timer
For i = 1 To 10
Range("A" & i).value = "Hello VBA"
Next i
Application.Screen Updating = True
MsgBox Program_Start_Time - Start & "Seconds"
End Function
Comments
Post a Comment