Results 1 to 3 of 3
  1. #1
    5 Star Lounger
    Join Date
    Jan 2004
    Location
    Praha
    Posts
    988
    Thanks
    56
    Thanked 105 Times in 90 Posts
    I want to change an Excel worksheet's tab colour if a cell within the sheet changes to a non-zero value.

    I know how to change the tab colour using VBA but am struggling to trap the event which triggers this.

    I was trying with this subroutine:

    Private Sub Worksheet_Change(ByVal Target As Range)
    ActiveWorkbook.Sheets("Checks").Tab.ColorIndex = 6
    End Sub

    (I am going to put the IF statement in later - this is a work-in-progress)

    But that subroutine is only triggered when the worksheet in question is active/open and I change any cell by typing into it. I want to trigger the subroutine when a linked cell in the sheet is changed by a change in some other sheet. I hope this makes sense - its an error-trapping process in a financial spreadsheet and the worksheet "Checks" is a summary of all possible errors anywhere in the Workbook.

    Although possible, it seems too clumsy to have a subroutine running every few seconds to make the change if required - but I do want to trap these events in real time because that's the best opportunity to correct a mistake.

    Grateful for any ideas.

    Martin

  2. #2
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Weert, Limburg, Netherlands
    Posts
    4,812
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You can use the Sheetcalculate event in the Thisworkbook module:

    Code:
    Private Sub Workbook_SheetCalculate(ByVal Sh As Object)
        ActiveWorkbook.Sheets("Checks").Tab.ColorIndex = 6
    End Sub
    Jan Karel Pieterse
    Microsoft Excel MVP, WMVP
    www.jkp-ads.com
    Professional Office Developers Association

  3. #3
    5 Star Lounger
    Join Date
    Jan 2004
    Location
    Praha
    Posts
    988
    Thanks
    56
    Thanked 105 Times in 90 Posts
    Perfect !

    Thank you.

    Martin

Posting Permissions

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