Conditional Format Via Code For Entire Workbook

  • I found code that I would like to use conditional formatting code as shown here. Here is the code just in case:


    But, how can I get this code to work across the entire workbook and not just for the specific worksheet? I tried pasting the code into the This Workbook under VBA Project and changing the Private to Public but no go.


    Thanks for any guidance.

  • Re: Vba Conditional Format Entire Workbook


    The code you have at the moment is in the change event for a particular worksheet.
    You need to place the same code in the


    Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)


    sub routine of the ThisWorkbook module.


    In the VBA editor open the module 'ThisWorkbook', this should be just under the module for the last worksheet in your workbook. In the dropdown menus just above the code window choose Workbook in the left and SheetChange in the right, then paste the code within the created subroutine.

  • Re: Conditional Format Via Code For Entire Workbook


    That worked like a charm! Thank you!


    One more question - how come it didn't update automatically basedd on the values I already had in the specified cells? That is, I had to go back through each cell, click in the formula bar and press enter for the cells that already had values? Can I make it do the updates for all of the cells that already have values?

  • Re: Conditional Format Via Code For Entire Workbook


    The code in question is only triggered by a change on in the workbook and only affects the cell that initiated the change.

  • Re: Conditional Format Via Code For Entire Workbook


    Is there code I could add to force it to run through the values already present in the cells without having the additional manual work?

  • Re: Conditional Format Via Code For Entire Workbook


    This could help.
    Just launch the macro.

    Triumph without peril brings no glory: Just try

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!