Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Sheet tab color

I have 1 sheet per tenant with their information and X amount of
tenants. The 4 cells that the macro looks at in each sheet are
different dates. For example Lease End Date is one of them. So 1st part
of the If is if the date of the lease end is today or past today make
the sheet tab Red. If its today +30 make it yellow so i know the lease
is ending. If its neither it makes it white. If one cell is true the
loop stops and jumps to the next sheet

Code:
Sub test()

Dim ws As Worksheet, rng
rng = Array(13, 16, 22, 27)
For Each ws In Worksheets
x = Application.Match(ws.Name, Array("AT&T Lease", "as"), 0)
If Not IsError(x) Then
With ws
For i = 0 To UBound(rng)
flag = False
Select Case .Range("b" & rng(i)).Value
Case Is <= Date
''''''.Tab.ColorIndex = 3
Application.Run ("TabRed"): flag = True
Case Is < Date + 30
''''''.Tab.ColorIndex = 6
Application.Run ("TabYellow"): flag = True
Case Else
''''' .Tab.ColorIndex = -4142
Application.Run ("TabWhite"): flag = False
End Select
If flag Then Exit For
Next
End With
End If
Next
End Sub
[/code]

The application "TabRed" is: ActiveWorkbook.Sheets("AT&T
Lease").Tab.ColorIndex = 3

I think "TabRed" is code i need to change to make this all work
correctly. But i tried to insert: ".Tab.ColorIndex = 3" instead and it
error's on me.

Is there any way to say change the sheet tab color that the loop is on
and not specify a sheet?

Thanks everyone in advance.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,298
Default Sheet tab color

Sub SetTabColors()
Dim ws As Worksheet
Dim clr As Long
For Each ws In ThisWorkbook.Worksheets
Select Case ws.Range("A1").Value
Case 1: clr = 3 'red
Case 2: clr = 6 'yellow
Case Else: clr = 2 'none
End Select
ws.Tab.ColorIndex = clr
Next
End Sub

"Leon" wrote:

I have 1 sheet per tenant with their information and X amount of
tenants. The 4 cells that the macro looks at in each sheet are
different dates. For example Lease End Date is one of them. So 1st part
of the If is if the date of the lease end is today or past today make
the sheet tab Red. If its today +30 make it yellow so i know the lease
is ending. If its neither it makes it white. If one cell is true the
loop stops and jumps to the next sheet

Code:
Sub test()

Dim ws As Worksheet, rng
rng = Array(13, 16, 22, 27)
For Each ws In Worksheets
x = Application.Match(ws.Name, Array("AT&T Lease", "as"), 0)
If Not IsError(x) Then
With ws
For i = 0 To UBound(rng)
flag = False
Select Case .Range("b" & rng(i)).Value
Case Is <= Date
''''''.Tab.ColorIndex = 3
Application.Run ("TabRed"): flag = True
Case Is < Date + 30
''''''.Tab.ColorIndex = 6
Application.Run ("TabYellow"): flag = True
Case Else
''''' .Tab.ColorIndex = -4142
Application.Run ("TabWhite"): flag = False
End Select
If flag Then Exit For
Next
End With
End If
Next
End Sub
[/code]

The application "TabRed" is: ActiveWorkbook.Sheets("AT&T
Lease").Tab.ColorIndex = 3

I think "TabRed" is code i need to change to make this all work
correctly. But i tried to insert: ".Tab.ColorIndex = 3" instead and it
error's on me.

Is there any way to say change the sheet tab color that the loop is on
and not specify a sheet?

Thanks everyone in advance.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Sheet tab color

Thanks for the help i just got it to work.

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
color fill button is not adding color to my spread sheet mitchnmd Excel Worksheet Functions 1 September 26th 07 04:36 PM
How can I change sheet tab color based on cell value in sheet? SCAScot Excel Programming 2 November 23rd 05 09:47 PM
Sheet Background Color Bill Helbron Excel Discussion (Misc queries) 2 April 14th 05 04:31 PM
sheet tab color in Excel X darnalli Excel Discussion (Misc queries) 1 December 15th 04 07:07 PM
sheet tab color johann Excel Programming 1 March 1st 04 02:21 AM


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

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

About Us

"It's about Microsoft Excel"