PC Review


Reply
Thread Tools Rate Thread

blank display while macro runs

 
 
RandyPerry
Guest
Posts: n/a
 
      8th Feb 2008
I run a macro in Excel that starts on tab 1, then goes to tab 2,3,4,5,etc.
and when it is finished, it returns to tab 1. When the macro runs, each of
the screens (tabs) flash by as the macro works on that tabs data and then
returns back to the beginning (tab 1). How can I keep the screen (tab 1)
active as the macro goes to each tab since it will end up at tab 1 at the end
of the macro?
 
Reply With Quote
 
 
 
 
JLGWhiz
Guest
Posts: n/a
 
      8th Feb 2008
Application.ScreenUpdating = False will help but if you have a lot of select
and activate in your code, it probably won't completely eliminate it. Also
don't forget to use Application.ScreenUpdating = True at the end of your
program.

"RandyPerry" wrote:

> I run a macro in Excel that starts on tab 1, then goes to tab 2,3,4,5,etc.
> and when it is finished, it returns to tab 1. When the macro runs, each of
> the screens (tabs) flash by as the macro works on that tabs data and then
> returns back to the beginning (tab 1). How can I keep the screen (tab 1)
> active as the macro goes to each tab since it will end up at tab 1 at the end
> of the macro?

 
Reply With Quote
 
Gord Dibben
Guest
Posts: n/a
 
      8th Feb 2008
You can do a lot of things to a sheet or sheets without selecting the sheet or
sheets.

If you post your code, someone may be able to clean it up.

As an alternative the screenupdating can be turned off as JLGWhiz points out.


Gord Dibben MS Excel MVP

On Thu, 7 Feb 2008 16:26:01 -0800, RandyPerry
<(E-Mail Removed)> wrote:

>I run a macro in Excel that starts on tab 1, then goes to tab 2,3,4,5,etc.
>and when it is finished, it returns to tab 1. When the macro runs, each of
>the screens (tabs) flash by as the macro works on that tabs data and then
>returns back to the beginning (tab 1). How can I keep the screen (tab 1)
>active as the macro goes to each tab since it will end up at tab 1 at the end
>of the macro?


 
Reply With Quote
 
RandyPerry
Guest
Posts: n/a
 
      8th Feb 2008
Thanks, JLGWhiz. It didn't stop the flashing as it worked on each sheet
before returning back to sheet 1.

Let me rephrase the question: Can I run a macro from sheet 1 without having
to activate each sheet I want the maco to work on, thus keeping sheet 1
active?

I use a button control on sheet 1 to run the macro. Sheet 1 is a summary
sheet that I use to operate several other macros that will take me to
individual sheets for local data work.

Here is some code that I'm using now:

Worksheets("W. Columbus Ave").Activate
Range("A6:A17").Select
Selection.ClearContents
Range("A6").Select
' ClearGenoa Macro
Worksheets("N. Genoa Ct").Activate
Range("A6:A11").Select
Selection.ClearContents
Range("A6").Select
' ClearFerdinand Macro
Worksheets("N. Ferdinand Ct").Activate
Range("A6:A12").Select
Selection.ClearContents
Range("A6").Select

This continues for 10 sheets and then makes sheet 1 active and selects cell
A2 to finish.

Regards
Randy

"JLGWhiz" wrote:

> Application.ScreenUpdating = False will help but if you have a lot of select
> and activate in your code, it probably won't completely eliminate it. Also
> don't forget to use Application.ScreenUpdating = True at the end of your
> program.
>
> "RandyPerry" wrote:
>
> > I run a macro in Excel that starts on tab 1, then goes to tab 2,3,4,5,etc.
> > and when it is finished, it returns to tab 1. When the macro runs, each of
> > the screens (tabs) flash by as the macro works on that tabs data and then
> > returns back to the beginning (tab 1). How can I keep the screen (tab 1)
> > active as the macro goes to each tab since it will end up at tab 1 at the end
> > of the macro?

 
Reply With Quote
 
RandyPerry
Guest
Posts: n/a
 
      8th Feb 2008
After getting the screenupdating=false/true where they needed to be, it
works! Thanks JLGWhiz,
Randy


"JLGWhiz" wrote:

> Application.ScreenUpdating = False will help but if you have a lot of select
> and activate in your code, it probably won't completely eliminate it. Also
> don't forget to use Application.ScreenUpdating = True at the end of your
> program.
>
> "RandyPerry" wrote:
>
> > I run a macro in Excel that starts on tab 1, then goes to tab 2,3,4,5,etc.
> > and when it is finished, it returns to tab 1. When the macro runs, each of
> > the screens (tabs) flash by as the macro works on that tabs data and then
> > returns back to the beginning (tab 1). How can I keep the screen (tab 1)
> > active as the macro goes to each tab since it will end up at tab 1 at the end
> > of the macro?

 
Reply With Quote
 
JLGWhiz
Guest
Posts: n/a
 
      8th Feb 2008
Randy, I took the code snippet you posted and "cleaned" it up to eliminate
the selects and activates.

Set Wks1 = Worksheets("W. Columbus Ave")
Wks1.Range("A6:A17").ClearContents
Set Wks2 = Worksheets("N. Genoa Ct")
WKs2.Range("A6:A11").ClearContents
Set Wks3 = Worksheets("N. Ferdinand Ct")
Wks3.Range("A6:A12").ClearContents

Using this style of code writing allows the code to execute without the
flicker and flash effect. The only thing is that you have to remember to
qualify all of your range objects with the sheet reference so it know where
to execute. Otherwise it assumes you want the active sheet to be the target.
You should practice up on this style if you will be doing a lot of code
writing, especially if you should decide to write a long program involving
more than one workbook and more than one sheet.
There are other little gimmicks that stop the flickering, like setting
calculation to manual. But the main thing is to get away from the select and
activate as much as possible. Sometimes, I still find it convenient to use
the activate method, but selection is no longer in my code.

"RandyPerry" wrote:

> After getting the screenupdating=false/true where they needed to be, it
> works! Thanks JLGWhiz,
> Randy
>
>
> "JLGWhiz" wrote:
>
> > Application.ScreenUpdating = False will help but if you have a lot of select
> > and activate in your code, it probably won't completely eliminate it. Also
> > don't forget to use Application.ScreenUpdating = True at the end of your
> > program.
> >
> > "RandyPerry" wrote:
> >
> > > I run a macro in Excel that starts on tab 1, then goes to tab 2,3,4,5,etc.
> > > and when it is finished, it returns to tab 1. When the macro runs, each of
> > > the screens (tabs) flash by as the macro works on that tabs data and then
> > > returns back to the beginning (tab 1). How can I keep the screen (tab 1)
> > > active as the macro goes to each tab since it will end up at tab 1 at the end
> > > of the macro?

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: macro runs only if cell not blank JLGWhiz Microsoft Excel Programming 0 16th Jun 2009 05:17 PM
Re: Message to display while macro runs Steve Schapel Microsoft Access Macros 0 30th Aug 2004 10:34 PM
Keep display steady while macro runs Salman Microsoft Excel Programming 3 6th Nov 2003 04:30 AM
Re: Display a message whilst a macro runs steve Microsoft Excel Programming 0 29th Oct 2003 07:37 PM
Re: Display a message whilst a macro runs Tom Ogilvy Microsoft Excel Programming 0 29th Oct 2003 12:43 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:16 AM.