Visual basic turn off screen updating

Free Excel Help One drawback with recorded macros in Excel is that the code produced is often very inefficient.

It also means that we cannot tell the macro recorder to not record our steps of selecting cells, sheets and scrolling around, even though the selecting of cells, sheets and scrolling is not needed in true VBA code.

visual basic turn off screen updating-13

The example hides every other column on Sheet1, while keeping track of the time it takes to do so.

The first time the example hides the columns, screen updating is turned on; the second time, screen updating is turned off. Hidden = True End If Next c stop Time = Time elapsed Time(i) = (stop Time - start Time) * 24 * 60 * 60 Next i Application.

I tried to disable screen refreshing by setting the WM_SETREDRAW flag of the active form to false (WIN32 API) but it does not have he desired effect: result = Send Message(ahwnd, WM_SETREDRAW, False, 0) Maybe there's a simple solution, but honestly, I searched the whole MSDN Januar edition and did not find anything useful.

Can anyone tell me the VB to stop my Excel Macro from updating the screen while it runs.

You may even find in some cases that Screen Updating is set back to true before your recorded macro completes.

This can happen with recorded macros that have the word Select used frequently.

Also, I use an Image-control on my welcome-screen which will move to keep centered on the resize event.

Until now, without the ability to disable screen refreshing, it looks very flickery. Any assistance would be appreciated Regards Roger Grilli I'm going on memory here because my API book is at work but: in the declarations section: Declare Lock Window Update Lib "GDI32" (By Val h Wnd as Long) As Long where you want to stop the screen from updating: Lock Window Update Form.h Wnd and where you want updating of the screen to start again: Lock Window Update 0 Make sure to check the declaration, because I'm not really sure about it.

Screen Updating = False at the beginning of your code, then if any user runs the code, they will not know what is going on and think that the computer system is not responding.

Tags: , ,