+ Reply to Thread
Results 1 to 11 of 11

Temporarily Disable Conditional Formatting when Printing

  1. #1
    Registered User
    Join Date
    12-10-2010
    Location
    Oxfordshire
    MS-Off Ver
    Excel 2010
    Posts
    13

    Temporarily Disable Conditional Formatting when Printing

    I'm after a macro to temporarily disable conditional formatting for a range of cells when printing.

    Or even just temporarily set the cell background colour to "no fill" and then have it restored after printing.

    The reason for this is I'm creating a bending schedule for steel reinforcement for concrete, and would like to warn the user that an invalid dimension has been entered using conditional formatting, however if the user really wants to continue I don't want the conditional formatting to show on prints, is this possible?

    Many thanks.
    Last edited by Maffia; 12-14-2010 at 08:25 AM.

  2. #2
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,056

    Re: Temporarily Disable Conditional Formatting when Printing

    I would use a helper cell for this. Add a check to the conditional format so that it checks if the helper cell is 1 as well as the original checks. Then you can use a BeforePrint event to set the helper cell to 0, thereby turning off the CF, print, then reset the cell to 1.
    Everyone who confuses correlation and causation ends up dead.

  3. #3
    Registered User
    Join Date
    12-10-2010
    Location
    Oxfordshire
    MS-Off Ver
    Excel 2010
    Posts
    13

    Re: Temporarily Disable Conditional Formatting when Printing

    Thank you for the quick response, can you expand on the BeforePrint event, I'm new to using macros.

  4. #4
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,056

    Re: Temporarily Disable Conditional Formatting when Printing

    In the ThisWorkbook module:
    Please Login or Register  to view this content.
    then in a normal module:
    Please Login or Register  to view this content.
    adjusting the range to suit.

  5. #5
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Temporarily Disable Conditional Formatting when Printing

    Unless you are using coloour elsewhere in the print, why not

    Please Login or Register  to view this content.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  6. #6
    Registered User
    Join Date
    12-10-2010
    Location
    Oxfordshire
    MS-Off Ver
    Excel 2010
    Posts
    13

    Re: Temporarily Disable Conditional Formatting when Printing

    Thank you, I will try that.

    I have colours elsewhere and text that I need hidden when printing, so is set to print in white which comes out black if set to print in black and white.

    OK, got it all working.

    Also can I get this to apply to any copies of the first sheet made, or just globally?

    And is it possible to get it working and allowing changes to the sheet name?
    Last edited by Maffia; 12-10-2010 at 11:15 AM.

  7. #7
    Registered User
    Join Date
    12-10-2010
    Location
    Oxfordshire
    MS-Off Ver
    Excel 2010
    Posts
    13

    Re: Temporarily Disable Conditional Formatting when Printing

    Can anyone help with the last two points?

  8. #8
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,056

    Re: Temporarily Disable Conditional Formatting when Printing

    Assuming you are using the altered CF, then just have all the CF point to the same flag cell and alter that. It will then affect all copies of the sheets. In order to allow changing the sheet name, use its code name in the routines rather than its tab name - e.g.:
    Please Login or Register  to view this content.

  9. #9
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,375

    Re: Temporarily Disable Conditional Formatting when Printing

    Only, in versions pre 2010 you can not refer to a cell in a different sheet in a CF formula.

    Therefore, create a range name that holds the flag instead of a cell in a specific sheet.

    Toggle the value of the named range with code like

    Please Login or Register  to view this content.
    and in the conditional formatting formula refer to the range CFflag instead of a specific cell in a specific sheet.

  10. #10
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,056

    Re: Temporarily Disable Conditional Formatting when Printing

    Or just name the cell and use that name in the CF formulas.

  11. #11
    Registered User
    Join Date
    12-10-2010
    Location
    Oxfordshire
    MS-Off Ver
    Excel 2010
    Posts
    13

    Re: Temporarily Disable Conditional Formatting when Printing

    Thank you very much, have got it working how I wanted.

+ 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