First attempt got closed as duplicate and I've used the suggested thread (VBA code doesn't run when cell is changed by a formula) & I've done some changes, but it still isn't working nothing happens.
I would like to change the color of a sheet tab based on the value of a cell (that has a formula in it) in a different sheet, but same workbook. The Different Sheet is the Master sheet "Test Summaries", and the cell I'd like to refer to is different for each sheet.
What I need:
- Tab "Microscopy" to change either color to red/orange/green based on the formula in Sheet "Test Summaries" cell"C2" (in this case Red) Tab
- "Culture" to change either color to red/orange/green based on the formula in Sheet "Test Summaries" cell "C3" (in this case Red)
- ...and so on
My updated code that is in the Sheet "Microscopy" object.
Private Sub Worksheet_Calculate1(ByVal Target As Range)
Dim MyVal$
MyVal = ActiveWorkbook.Sheets("Test Summaries").Range("C2")
With ActiveSheet.Tab
Select Case MyVal
Case "RED"
.Color = vbRed
Case "GREEN"
.Color = vbGreen
Case "AMBER"
.ColorIndex = 45
End Select
End With
End Sub
Private Sub Worksheet_Calculate()
If Range("A1").Value <> PrevVal Then
MsgBox "Value Changed"
PrevVal = Range("A1").Value
End If
End Sub
But this didn't work (nothing happens), so then I added the following based on thread I've made some changes to my code, but nothing happens.
This code into ThisWorkbook Objects (but I don't understand what it's suppose to do, but it doesn't seem right as I need each tab to refer to a different cell)
Private Sub Workbook_Open()
PrevVal = Sheet1.Range("C3").Value
End Sub
Then in the Modules 1 I've put this
Private Sub Workbook_Open()
PrevVal = Sheet1.Range("C3").Value
End Sub
I would really appreciate help. btw I'm working in excel 2010