macro for Tab colour change

M

Mike

This is what i have but the problem is when i type something in cell the Tab
changes colour this is good & when i clear cell i want Tab to go back to its
original colour is this possible

Private Sub Workbook_SheetChange(ByVal Sh As Object, _
ByVal Target As Range)
If Intersect(Target, Range("B300")) Is Nothing Then Exit Sub
ActiveSheet.Tab.ColorIndex = 15
End Sub
 
R

Rik_UK

You could try this...

Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
If Intersect(Target, Range("B300")) Is Nothing Then
ActiveSheet.Tab.ColorIndex = 15
Else
ActiveSheet.Tab.ColorIndex = [put original colorindex here]
End if
End Sub

Hope it helps...
 
M

Mike H

Mike,

Try this

Private Sub Workbook_SheetChange(ByVal Sh As Object, _
ByVal Target As Range)
If Intersect(Target, Range("B300")) Is Nothing Then Exit Sub
Select Case Target.Value
Case Is = ""
ActiveSheet.Tab.Color = xlAutomatic
Case Else
ActiveSheet.Tab.Color = 15
End Select
End Sub

Mike
 
R

Rik_UK

An elementary error in my code, should have been:

Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
If Intersect(Target, Range("B300")) Is Nothing Then Exit Sub
If Target.Value <> "" Then
ActiveSheet.Tab.ColorIndex = 15
Else
ActiveSheet.Tab.ColorIndex = [original ColorIndex]
End If
End Sub

With thanks to Mike H's answer to make me realise this...

--
Kind regards

Rik


Rik_UK said:
You could try this...

Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
If Intersect(Target, Range("B300")) Is Nothing Then
ActiveSheet.Tab.ColorIndex = 15
Else
ActiveSheet.Tab.ColorIndex = [put original colorindex here]
End if
End Sub

Hope it helps...

--
Kind regards

Rik


Mike said:
This is what i have but the problem is when i type something in cell the Tab
changes colour this is good & when i clear cell i want Tab to go back to its
original colour is this possible

Private Sub Workbook_SheetChange(ByVal Sh As Object, _
ByVal Target As Range)
If Intersect(Target, Range("B300")) Is Nothing Then Exit Sub
ActiveSheet.Tab.ColorIndex = 15
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top