Logo 
Search:

MS Office Forum

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds

Changing Tab Color Excel 2003

  Asked By: Nancy    Date: Mar 11    Category: MS Office    Views: 1204
  

Sorry for this, but I want to, using vba, change the tab color based
on a value in a worksheet cell, in this case O7. It would have to or 3
values, so I assume an if statement, but can't quite get ti.

Share: 

 

3 Answers Found

 
Answer #1    Answered By: Sarah Campbell     Answered On: Mar 11

mysheet.Tab.Color=myrange.Interior.Color

 
Answer #2    Answered By: Gloria Cook     Answered On: Mar 11

Can you use if statements in that?
Such as, if cell O7 = "Plate" color  = Blue if cell O7 = "Rod" color = Green,
etc.

 
Answer #3    Answered By: Kaysah Mohammad     Answered On: Mar 11

Sure, but use them in a select case statement

Sub ChangeTabColors()
Dim MySheet As Worksheet
Set MySheet = ActiveSheet
Select Case MySheet.Range("O7").Value

Case "Plate"
MySheet.Tab.Color = RGB(0, 0, 255)
Case "Rod"
MySheet.Tab.Color = RGB(0, 255, 0)
Case Else
MySheet.Tab.Color = RGB(127, 127, 127)
End Select
End Sub

Note:
RGB Colors:
Color: Red Value, Green Value, Blue Value
Black: 0, 0, 0
Blue: 0, 0, 255
Green: 0, 255, 0
Cyan: 0, 255, 255
Red: 255, 0, 0
Magenta: 255, 0, 255
Yellow: 255, 255, 0
White: 255, 255, 255

Grey: 127, 127, 127

 
Didn't find what you were looking for? Find more on Changing Tab Color Excel 2003 Or get search suggestion and latest updates.




Tagged: