ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Changing tab color continued (https://www.excelbanter.com/excel-programming/413004-changing-tab-color-continued.html)

Amie

Changing tab color continued
 
This is great thank you. Another question what if I want to say:

If any of the cells in the worksheet are colored yellow then color
the
tab yellow? Here is the code that I have written but this is only
good for column 1


Private Sub Worksheet_SelectionChange(ByVal Target As Range)


Dim iRow As Integer
iRow = 1


Do Until iRow = 300
If Cells(iRow, 1).Interior.Color = 65535 Then
With ActiveSheet.Tab
.Color = 65535
End With
Exit Do
Else
With ActiveSheet.Tab
.Color = 0
End With
End If
iRow = iRow + 1


Loop


End Sub



Don Guillett

Changing tab color continued
 
You should STAY in the ORIGINAL thread. Try this idea.

Sub cc()
For Each c In ActiveSheet.UsedRange
If c.Interior.ColorIndex 0 Then MsgBox c.Row
Next c
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Amie" wrote in message
...
This is great thank you. Another question what if I want to say:

If any of the cells in the worksheet are colored yellow then color
the
tab yellow? Here is the code that I have written but this is only
good for column 1


Private Sub Worksheet_SelectionChange(ByVal Target As Range)


Dim iRow As Integer
iRow = 1


Do Until iRow = 300
If Cells(iRow, 1).Interior.Color = 65535 Then
With ActiveSheet.Tab
.Color = 65535
End With
Exit Do
Else
With ActiveSheet.Tab
.Color = 0
End With
End If
iRow = iRow + 1


Loop


End Sub





All times are GMT +1. The time now is 01:19 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com