I am trying to create a macro that will divide a cell value and if the value is more than 7.5, then colour the cell dark green and then keep on colouring the subsequent cells dark green, for instance 2.25 would be 2 cells dark green and the .25 light green. Moreover, if the colour content of the cell, which is to be coloured, is grey then keep on moving the activecell until it is on a cell with no colour.
For Each y In rng If Not IsEmpty(y) And y > 7.5 And y <> "" And IsNumeric(y) Then 'I am having trouble here y.Select With ActiveCell.Offset(0, i).Interior .Pattern = xlSolid .PatternColorIndex = xlAutomatic .ThemeColor = xlThemeColorAccent3 .TintAndShade = -0.249977111117893 .PatternTintAndShade = 0 End With col = y.Value / 7.5 Count = Left(col, Len(col) - InStr(1, col, ".")) For i = 1 To Count Do While ActiveCell.Offset(0, i).TintAndShade = -0.149998474074526 i = i + 1: Count = Count + 1 Loop ActiveCell.Offset(0, i).Select With Selection.Interior .Pattern = xlSolid .PatternColorIndex = xlAutomatic .ThemeColor = xlThemeColorAccent3 .TintAndShade = -0.249977111117893 .PatternTintAndShade = 0 End With Next i Count = Right(col, Len(col) - InStr(1, col, ".")) If Count > 0 And Count < 25 Then ActiveCell.TintAndShade = -4.99893185216834E-02 ElseIf Count > 26 And Count < 50 Then ActiveCell.TintAndShade = 0.799981688894314 ElseIf Count > 75 And Count < 100 Then ActiveCell.TintAndShade = 0.599993896298105 End If Next y End If Next y The macro is for showing workload across the week, with the greyed cells being weekend, so they would need to be skipped.