+ Reply to Thread
Results 1 to 3 of 3

macro slow after printing

  1. #1
    Forum Contributor
    Join Date
    07-07-2005
    Location
    England
    MS-Off Ver
    Office 2019 Enterprise
    Posts
    462

    macro slow after printing

    Hello, has anyone come across this problem before..

    I have some code which looks in each cell and hides the row if it meets a certain criteria. If i run the code it works instantaneously but after printing the worksheet (or print previewing it) the code takes ages.

    Is there an obvious reason for this?

    Thanks

    John

  2. #2
    Norman Jones
    Guest

    Re: macro slow after printing

    Hi John,

    It is likely that the hiding of rows is causing Excel repeatedly to
    recalculate the position of pagebreaks, which can be very slow.

    Try wapping your code something like:

    On Error GoTo XIT

    With Application
    CalcMode = .Calculation
    .Calculation = xlCalculationManual
    .ScreenUpdating = False
    End With

    With ActiveWindow
    ViewMode = .View
    .View = xlNormalView
    End With

    SH.DisplayPageBreaks = False


    'YOUR CODE '<<====


    XIT:
    With Application
    .Calculation = CalcMode
    .ScreenUpdating = True
    End With

    ActiveWindow.View = ViewMode

    End Sub


    ---
    Regards,
    Norman



    "johncassell" <[email protected]>
    wrote in message
    news:[email protected]...
    >
    > Hello, has anyone come across this problem before..
    >
    > I have some code which looks in each cell and hides the row if it meets
    > a certain criteria. If i run the code it works instantaneously but after
    > printing the worksheet (or print previewing it) the code takes ages.
    >
    > Is there an obvious reason for this?
    >
    > Thanks
    >
    > John
    >
    >
    > --
    > johncassell
    > ------------------------------------------------------------------------
    > johncassell's Profile:
    > http://www.excelforum.com/member.php...o&userid=25016
    > View this thread: http://www.excelforum.com/showthread...hreadid=513682
    >




  3. #3
    Forum Contributor
    Join Date
    07-07-2005
    Location
    England
    MS-Off Ver
    Office 2019 Enterprise
    Posts
    462
    Cheers Norman, I wrapped my code but it made my code not work at all!

    I simply cut sh.DisplayPageBreaks = False from your code and put it at the top of mine which worked perfectly.

    Thanks very much.

    John

+ 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