Hello everyone,
I worte ths code tonight, because I need a graphic report of how many days the machines are busy, this is my code
Code
Sub machinesrgaphic()
Dim c As Range
Dim ws As Worksheet
Set ws = Sheets("CARICO MACCHINE")
Application.ScreenUpdating = False
For Each c In ws.Range("C3", ws.Range("C" & ws.Rows.Count).End(xlUp))
If c.Value > 1 And c.Value < 2 Then
c.Offset(, 1).Resize(1, 2).Interior.ColorIndex = 33
ElseIf c.Value > 2 And c.Value < 3 Then
c.Offset(, 1).Resize(1, 3).Interior.ColorIndex = 33
ElseIf c.Value > 3 And c.Value < 4 Then
c.Offset(, 1).Resize(1, 4).Interior.ColorIndex = 33
ElseIf c.Value > 4 And c.Value < 5 Then
c.Offset(, 1).Resize(1, 5).Interior.ColorIndex = 33
ElseIf c.Value > 5 And c.Value < 6 Then
c.Offset(, 1).Resize(1, 6).Interior.ColorIndex = 33
ElseIf c.Value > 6 And c.Value < 7 Then
c.Offset(, 1).Resize(1, 7).Interior.ColorIndex = 33
ElseIf c.Value > 7 And c.Value < 8 Then
c.Offset(, 1).Resize(1, 8).Interior.ColorIndex = 33
ElseIf c.Value > 8 And c.Value < 9 Then
c.Offset(, 1).Resize(1, 9).Interior.ColorIndex = 33
ElseIf c.Value > 9 And c.Value < 10 Then
c.Offset(, 1).Resize(1, 10).Interior.ColorIndex = 33
ElseIf c.Value > 10 And c.Value < 11 Then
c.Offset(, 1).Resize(1, 11).Interior.ColorIndex = 33
ElseIf c.Value > 11 And c.Value < 12 Then
c.Offset(, 1).Resize(1, 12).Interior.ColorIndex = 33
ElseIf c.Value > 12 And c.Value < 13 Then
c.Offset(, 1).Resize(1, 13).Interior.ColorIndex = 33
ElseIf c.Value > 13 And c.Value < 14 Then
c.Offset(, 1).Resize(1, 14).Interior.ColorIndex = 33
End If
Next c
Application.ScreenUpdating = True
End Sub
Display More
Now it works perfectly, but there are too many Else ifs, and I need to add some more, because I need to arrive at 30 (days) to be represented by colored cells.
I simplified the condition, but what I mean is how do I define a J or an X and tell the code that if cell value is X than he has to color the X number of cells adiacent to that cell? Without having to specify so many conditions?
Thank you in advance for any input and suggestions!