Click here to Skip to main content
15,888,803 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
I tried this code below to get the tabcolor of a workbook excel:

VB
dim xcolor as string = worksheet.tabcolor.tostring


but it doesnt work.

I just want semething that will show like this:

VB
xcolor = RED (if the tabcolor is red)
Posted
Updated 28-Sep-15 22:16pm
v2
Comments
Richard MacCutchan 29-Sep-15 4:00am    
What does "it doesnt work" mean?

1 solution

You need the property called "ColorIndex":[^]

VB
Dim xcolor as Integer = Sheets("Sheet1").Tab.ColorIndex
 '3=Red , 4=green,5=blue,6=yellow,etc...

If xcolor = 3 Then
'do something
End If
 
Share this answer
 
Comments
Maciej Los 29-Sep-15 13:00pm    
+5!
Leo Chapiro 29-Sep-15 15:20pm    
Thank you Maciej! :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900