+ Reply to Thread
Results 1 to 4 of 4

Macro slows down when I print/print preview/page break a sheet

  1. #1
    Registered User
    Join Date
    09-11-2012
    Location
    SF
    MS-Off Ver
    Excel 2010
    Posts
    2

    Macro slows down when I print/print preview/page break a sheet

    Hello -

    I have a workbook that the user will select Y/N on the "Overview" tab. This triggers a true / false if statement on the "Benefits" tab. I have a macro running on the benefits tab that will hide all rows with False in column D (See below) and only the appropriate benefits will remain showing.

    Sub Worksheet_Calculate()
    Dim Cell As Range
    Application.ScreenUpdating = False
    Application.EnableEvents = False
    For Each Cell In Range("D3:D700")
    Cell.EntireRow.Hidden = Cell.Value = False
    Next
    Application.EnableEvents = True
    Application.ScreenUpdating = True
    End Sub

    This macro works fine. The issues is when I go to either print, set the page breaks, or print preview, the macro will run extremely slow thereafter. I believe the problem is is that excel is calculating page breaks from D3 to D700. Anyone no I can I avoid this?

    Thank you

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,447

    Re: Macro slows down when I print/print preview/page break a sheet

    I'd say just use the worksheet change event on the Overview sheet to hide the rows on the Benefits sheet. And it would be quicker if you built a range using Union and hiding all the rows in one go.

    Whatever, I think you need to lose the worksheet calculate event.

    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Registered User
    Join Date
    09-11-2012
    Location
    SF
    MS-Off Ver
    Excel 2010
    Posts
    2

    Re: Macro slows down when I print/print preview/page break a sheet

    Can you explain a little more on the worksheet change event? I am might very familiar with VBA.

    Thanks

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,447

    Re: Macro slows down when I print/print preview/page break a sheet

    Please post a sample workbook. I will look at it for you in the morning (UK morning)

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Print area will not keep when using Page Break Preview
    By viridescent in forum Excel General
    Replies: 1
    Last Post: 01-24-2013, 10:16 AM
  2. page break preview vs print preview do not match
    By chadgar24 in forum Excel General
    Replies: 1
    Last Post: 05-16-2012, 11:32 AM
  3. VBA Macro shows Print Preview page: How to auto-maximize the Print Preview?
    By jonvanwyk in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-06-2010, 04:48 PM
  4. Print Preview Doesn't Match Page Break Preview
    By mik7585 in forum Excel General
    Replies: 0
    Last Post: 06-01-2009, 11:32 AM
  5. Page Break/Print Preview Issue
    By axslinger in forum Excel General
    Replies: 2
    Last Post: 03-26-2009, 08:52 PM

Tags for this Thread

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