Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Macro to change color of tab based on color of cell

Hello -

I would like to write a macro that will change the color of the
worksheet tab based on the color of cells. For example I have
conditional formating that will highlight cells in yellow. I want a
macro that says:

If cells in worksheet change to yellow
then
Change the tab to yellow

Can anyone help me with this?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,101
Default Macro to change color of tab based on color of cell

Sub Macro1()
If Range("A1").Interior.Color = 65535 Then
With ActiveSheet.Tab
.Color = 65535
End With
End If
End Sub

"Amie" wrote:

Hello -

I would like to write a macro that will change the color of the
worksheet tab based on the color of cells. For example I have
conditional formating that will highlight cells in yellow. I want a
macro that says:

If cells in worksheet change to yellow
then
Change the tab to yellow

Can anyone help me with this?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,101
Default Macro to change color of tab based on color of cell

paste this into the sheet you want the tab color to change
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Range("A1").Interior.Color = 65535 Then
With ActiveSheet.Tab
.Color = 65535
End With
Else
With ActiveSheet.Tab
.Color = 0
End With
End If
End Sub

"Amie" wrote:

Hello -

I would like to write a macro that will change the color of the
worksheet tab based on the color of cells. For example I have
conditional formating that will highlight cells in yellow. I want a
macro that says:

If cells in worksheet change to yellow
then
Change the tab to yellow

Can anyone help me with this?

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Macro to change color of tab based on color of cell

On Jun 23, 11:20*am, Mike wrote:
paste this into the sheet you want the tab color to change
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
* * If Range("A1").Interior.Color = 65535 Then
* * With ActiveSheet.Tab
* * * * .Color = 65535
* * End With
* * Else
* * With ActiveSheet.Tab
* * * * .Color = 0
* * End With
* * End If
End Sub



"Amie" wrote:
Hello -


I would like to write a macro that will change the color of the
worksheet tab based on the color of cells. *For example I have
conditional formating that will highlight cells in yellow. *I want a
macro that says:


If cells in worksheet change to yellow
then
Change the tab to yellow


Can anyone help me with this?- Hide quoted text -


- Show quoted text -


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
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Macro to change color of tab based on color of cell

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


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,101
Default Macro to change color of tab based on color of cell

I guess you could do another loop but checking each cell will greatly
so down performance. Maybe someone else has a better idea for you.
Private Sub Worksheet_SelectionChange(ByVal Target As Range)

Dim iRow As Integer
Dim iColumn As Integer

iColumn = 1
Do Until iColumn 3
iRow = 1
Do Until iRow 300
If Cells(iRow, iColumn).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
iColumn = iColumn + 1
Loop
End Sub

"Amie" wrote:

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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Change tab color based on current color of a cell MarkT Excel Discussion (Misc queries) 0 May 22nd 08 05:46 PM
Can you change the color of one cell based on the color of another andoscott Excel Discussion (Misc queries) 4 May 4th 07 04:02 PM
change cell color based on a tab color Michael Excel Programming 3 August 24th 06 09:03 PM
change fill color of a range of cells based on color of a cell? DarMelNel Excel Programming 0 March 2nd 06 06:35 PM
Browse Forms Controls and change TextBox color based on cell color StefanW Excel Programming 2 November 21st 04 07:06 PM


All times are GMT +1. The time now is 05:35 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"