View Single Post
 
Old 03-02-2017, 03:07 PM
Logit Logit is offline Windows 10 Office 2007
Expert
 
Join Date: Jan 2017
Posts: 587
Logit is a jewel in the roughLogit is a jewel in the roughLogit is a jewel in the roughLogit is a jewel in the rough
Default

Paste this macro in the ThisWorkbook module of your project. Save the workbook as Macro Enabled. When the workbook is opened again this macro will be initiated.

You can change the tab color as indicated at the top of the macro by changing the number :

Code:

Private oldindex         As Integer
Const lTAB_COLOUR    As Long = 5   '<--- change color number here
Sub workbook_sheetactivate(ByVal Sh As Object)
   oldindex = Sh.Tab.ColorIndex
   Sh.Tab.ColorIndex = lTAB_COLOUR
End Sub

Sub workbook_sheetdeactivate(ByVal Sh As Object)
   If oldindex <> 0 Then
      If Sh.Tab.ColorIndex = lTAB_COLOUR Then Sh.Tab.ColorIndex = oldindex
   End If
End Sub
Reply With Quote