ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Hide screen movements when a macro is running (https://www.excelbanter.com/excel-discussion-misc-queries/253030-hide-screen-movements-when-macro-running.html)

STatAGL

Hide screen movements when a macro is running
 
I generally create Macros by recording keystrokes.
One macro I have moves around the spreadsheet for about 5 minutes, copying,
pasting etc etc
But I do not want the user of the spreadsheet to see all the
movements...even though they are so quick...effectively is there a way to
'freeze the screen' at the start of the macro...so all the movement is
hidden. It may be something I have to turn back on again at the end of the
macro?

Thanks for any help available

ExcelBanter AI

Answer: Hide screen movements when a macro is running
 
Yes, there is a way to hide screen movements when a macro is running. You can use the Application.ScreenUpdating property to turn off screen updating at the beginning of your macro and turn it back on at the end. This will prevent the user from seeing all the movements and make the macro run faster.

Here's how you can do it:
  1. Open the VBA editor by pressing Alt + F11.
  2. In the Project Explorer window, double-click on the module that contains your macro.
  3. At the beginning of your macro, add the following line of code to turn off screen updating:

    Code:

    Application.ScreenUpdating = False
  4. At the end of your macro, add the following line of code to turn on screen updating:

    Code:

    Application.ScreenUpdating = True

That's it! Now when you run your macro, the screen will freeze at the beginning and the user won't be able to see all the movements. Once the macro is finished, the screen will unfreeze and the user will be able to see the final result.

Note: If your macro encounters an error and stops running before it reaches the line that turns screen updating back on, the screen will remain frozen. To avoid this, you can add an error handler to your macro that turns screen updating back on even if an error occurs.

L. Howard Kittle

Hide screen movements when a macro is running
 
At the beginning

Application.ScreenUpdating = False

and at the end

Application.ScreenUpdating = True

HTH
Regards,
Howard


"STatAGL" wrote in message
...
I generally create Macros by recording keystrokes.
One macro I have moves around the spreadsheet for about 5 minutes,
copying,
pasting etc etc
But I do not want the user of the spreadsheet to see all the
movements...even though they are so quick...effectively is there a way to
'freeze the screen' at the start of the macro...so all the movement is
hidden. It may be something I have to turn back on again at the end of
the
macro?

Thanks for any help available




STatAGL

Hide screen movements when a macro is running
 
Thanks Howard...that worked perfectly. Much appreciated!!!!

"L. Howard Kittle" wrote:

At the beginning

Application.ScreenUpdating = False

and at the end

Application.ScreenUpdating = True

HTH
Regards,
Howard


"STatAGL" wrote in message
...
I generally create Macros by recording keystrokes.
One macro I have moves around the spreadsheet for about 5 minutes,
copying,
pasting etc etc
But I do not want the user of the spreadsheet to see all the
movements...even though they are so quick...effectively is there a way to
'freeze the screen' at the start of the macro...so all the movement is
hidden. It may be something I have to turn back on again at the end of
the
macro?

Thanks for any help available



.


L. Howard Kittle

Hide screen movements when a macro is running
 
You are welcome, thanks for the feed back.

H'wd

"STatAGL" wrote in message
...
I generally create Macros by recording keystrokes.
One macro I have moves around the spreadsheet for about 5 minutes,
copying,
pasting etc etc
But I do not want the user of the spreadsheet to see all the
movements...even though they are so quick...effectively is there a way to
'freeze the screen' at the start of the macro...so all the movement is
hidden. It may be something I have to turn back on again at the end of
the
macro?

Thanks for any help available





All times are GMT +1. The time now is 12:05 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com