Hi guys,
I have an array showing numbers 1 to 7 I am having vba check a column for the max number for the week and filling them with color..
The problem I am having here is that I am using an if and elseif statements.. If 7 is not existent mark 6 else is 6 is not existent so on..
While looping through the column excel is marking 5 and 6 when I just wanted the highest value marked from 1 to 7
Sorry I know I am new and this probably looks like real bad coding... = (
Any help would be appreciated
Thanks,
I have an array showing numbers 1 to 7 I am having vba check a column for the max number for the week and filling them with color..
The problem I am having here is that I am using an if and elseif statements.. If 7 is not existent mark 6 else is 6 is not existent so on..
While looping through the column excel is marking 5 and 6 when I just wanted the highest value marked from 1 to 7
Code:
Set aCell = ActiveSheet.UsedRange.Find(What:="VPW", LookIn:=xlValues, _
LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False)
dayWeek = Array(1, 2, 3, 4, 5, 6, 7)
largest = aCell.Column
For Each a In Intersect(Range("N:N"), ActiveSheet.UsedRange)
For mcount = 1 To 7
If a.Value = Application.Max(dayWeek) Then
Range(Cells(a.Row, largest).Address).Select
Selection.Interior.Color = RGB(0, 176, 240)
ElseIf a.Value <> 7 And a.Value = Application.Max(dayWeek) - 1 Then
Range(Cells(a.Row, largest).Address).Select
Selection.Interior.Color = RGB(0, 176, 240)
ElseIf a.Value <> 6 And a.Value = Application.Max(dayWeek) - 2 Then
Range(Cells(a.Row, largest).Address).Select
Selection.Interior.Color = RGB(0, 176, 240)
End If
Exit For
Exit For
Sorry I know I am new and this probably looks like real bad coding... = (
Any help would be appreciated
Thanks,
Last edited by a moderator: