Little Help with formula for tracking days worked

mikeym

New Member
Joined
Jan 1, 2012
Messages
15
I need to track what days a person worked and the if they work 7 or more days in a row have it highlight those days ( say if I worked 9 days in row those cells would change to Red).
I will tracking this for a full year.

The formula I started using was =IF(ISNUMBER(MATCH("mike",C7:C18,0)),"Yes","No") Just could not figure out how to do the color change part.

Thanks for any help ..:)
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
Use conditional formatting. In what column are the days that you want to highlight?
 
Upvote 0
Conditional Would not do what I need I don't think. I am pulling the data from another sheet and I will be highlighting multiple columns for different People.
I think I just really need help getting it to change cell colors when the person work 7 or more days in a row.
Thanks fro trying to help me
 
Upvote 0
A formula is not going to change the color of cells. Conditional formatting will, based on whatever you want. What column do you want to highlight? What column are the dates in? What does your data look like?
 
Upvote 0
Just simple Names in column A and dates going across top, If the mike worked on Jan 1st I would have Yes in cell b2...Make sense?
Jan 1Jan 2
MikeYesNo
 
Upvote 0
Interesting! Save a back-up of your workbook, then try this code:

Code:
Sub highlightDays()


Dim myRow As Long, myCol As Long, myCount As Integer
Dim lastRow As Long, lastCol As Long


lastRow = Cells(Rows.Count, 1).End(xlUp).Row
lastCol = Cells(1, Columns.Count).End(xlToLeft).Column


For myRow = 2 To lastRow
    myCount = 0
    For myCol = 2 To lastCol
        If Cells(myRow, myCol).Value = "Yes" Then
            myCount = myCount + 1
        Else
            myCount = 0
        End If
        If myCount >= 3 Then
            Range(Cells(myRow, myCol), Cells(myRow, myCol - myCount + 1)).Interior.ColorIndex = 6
        End If
    Next myCol
Next myRow


End Sub
 
Upvote 0
Ah, good point. How about this fix:

Code:
Sub highlightDays()


Dim myRow As Long, myCol As Long, myCount As Integer
Dim lastRow As Long, lastCol As Long


lastRow = Cells(Rows.Count, 1).End(xlUp).Row
lastCol = Cells(1, Columns.Count).End(xlToLeft).Column


For myRow = 2 To lastRow
    myCount = 0
    For myCol = 2 To lastCol
        If Cells(myRow, myCol).Value = "Yes" or Cells(myRow,myCol).Value = "yes" Then
            myCount = myCount + 1
        Else
            myCount = 0
        End If
        If myCount >= 3 Then
            Range(Cells(myRow, myCol), Cells(myRow, myCol - myCount + 1)).Interior.ColorIndex = 6
        End If
    Next myCol
Next myRow


End Sub
 
Upvote 0

Forum statistics

Threads
1,215,949
Messages
6,127,892
Members
449,411
Latest member
AppellatePerson

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top