Sub RectangleBeveled3_Click()
Dim rNo, rStart As Integer
Dim cNo, cStart As Integer
cNo = Worksheets(1).UsedRange.Columns.Count
rNo = Worksheets(1).UsedRange.Rows.Count
cStart = 10
rStart = 8
Rem MsgBox ("cNo:" & cNo & " " & "rNo:" & rNo & "")
Rem End
Dim iValue, iPlanStart, iPlanEnd As Date
Dim iStatus As String
For a = rStart To rNo 'from row8 to rowMax
iStatus = LCase(Cells(a, 4))
iPlanStart = Cells(a, 6)
iPlanEnd = Cells(a, 7)
For b = cStart To cNo 'from column8 to columnDMax
Rem MsgBox ("Row:" & a & "\nr" & "Col:" & b & "\nr")
Rem Exit For
iValue = Cells(6, b)
If iValue <= iPlanEnd And iValue >= iPlanStart Then
If iStatus = "ongoing" Then
Cells(a, b).Interior.Color = RGB(255, 255, 0) 'yellow color
ElseIf iStatus = "done" Then
Cells(a, b).Interior.Color = RGB(0, 176, 80) 'green color
ElseIf iStatus = "blocked" Then
Cells(a, b).Interior.Color = RGB(255, 0, 0) 'red color
Else
'nothing
End If
Else
Cells(a, b).Interior.Color = RGB(255, 255, 255) 'white color
End If
If b = 20 Then
Rem MsgBox ("Row:" & a & "\nr" & "Col:" & b & "\nr")
Rem Exit For
End If
Next
Next
a = a - 1
b = b - 1
Dim CNtoW As String
CNtoW = Replace(Cells(1, b).Address(False, False), "1", "") ' convert number to column alphabet
Set Rng = Range("J8:" & CNtoW & a)
Rng.Borders.LineStyle = xlHairline
MsgBox ("Finish")
End Sub