Screen updating propose dating online
One quick and easy technique to make your code run faster in Excel VBA is to simply prevent the screen from being redrawn each time something changes.
You can achieve this by using the Screen Updating property of the Application object.
This means that if you run a different subroutine after the one above and you haven't added the line of code to disable screen updates to it, you'll be able to see the screen updating in the background.
You may have noticed that when running the procedure with screen updates disabled the subroutine appeared to run faster.
This should certainly be the case as Excel doesn't have to continually redraw the screen each time something changes.
If we want to quantify how much time we've saved we can add some code to create a basic timer system.
The general structure of our timer is shown below: This isn't the most accurate timer system you can create in VBA but it's good enough for our example.Should you need something a little more accurate you might want to investigate the Timer function instead.Alternatively, if you're feeling ambitious, you might consider using some Windows API functions to create incredibly accurate timers.When you run the subroutine again you should now see the time taken in seconds displayed at the end of the procedure.