+ Reply to Thread
Results 1 to 5 of 5

Smoothing transition using VBA with selecting sheets

  1. #1
    Registered User
    Join Date
    06-30-2009
    Location
    Cabot, AR
    MS-Off Ver
    Excel 2013
    Posts
    9

    Smoothing transition using VBA with selecting sheets

    I have created a macro that goes from my main sheet to the data sheet and changes all the pivot tables to match. One thing I hate about it is that it is not very fluid. It jumps from the first page to the second (due to the sheets("data") function. Is there a way to make it change the pivot tables on the second sheet without actually have to have the macro select the second sheet?

    Thanks in advance.

    Please Login or Register  to view this content.
    Last edited by robinterrell; 11-13-2009 at 05:47 PM.

  2. #2
    Forum Contributor
    Join Date
    09-22-2009
    Location
    Indianapolis, Indiana
    MS-Off Ver
    Office 2003 / Office 2007
    Posts
    114

    Re: Smoothing transition using VBA with selecting sheets

    Just add:

    Application.ScreenUpdating = False

    <code here>

    Application.ScreenUpdating = True

    This will prevent it. Also you do not have to use ActiveSheet etc, you can directly reference the sheet which avoids the need to even switch which sheet is active. Instead of:

    Please Login or Register  to view this content.
    use

    Please Login or Register  to view this content.
    Or

    Please Login or Register  to view this content.
    (Or, if you have several to change...)

    Please Login or Register  to view this content.
    Additionally this is MUCH faster. If you are using code that "touches" a lot of cells it will be quite slow. This type of code is generated by the Macro Recorder, and usually needs to be edited after it is recorded to avoid this type of problem.

  3. #3
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Smoothing transition using VBA with selecting sheets

    Please Login or Register  to view this content.
    You don't fill in individual cells one a time with the same value. You do it all at once:
    Please Login or Register  to view this content.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  4. #4
    Forum Contributor
    Join Date
    09-22-2009
    Location
    Indianapolis, Indiana
    MS-Off Ver
    Office 2003 / Office 2007
    Posts
    114

    Re: Smoothing transition using VBA with selecting sheets

    It was simply an example and I used 1 for illustration. It could just as easily have been "cat" and "dog".

  5. #5
    Registered User
    Join Date
    06-30-2009
    Location
    Cabot, AR
    MS-Off Ver
    Excel 2013
    Posts
    9

    Re: Smoothing transition using VBA with selecting sheets

    Thank you both!!!!! This worked GREAT!!!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1