I have a terrible headache on the following conditions:

The difference between a date given in cell (i, 9) and NOW() should undergo the IF procedures set presented below in the macro - in another cell (i, 13) it should display certain text with coloring (warning).
However, if (i, 9) is empty, then cell (i, 10) should follow the same set of IFs.
If there is nothing in both cells, the warning cell (i, 13) should remain empty.

I was able to create only the first condition, which is working fine, however, I have no idea how to approach the second one. Does anyone have an idea how to create a loop where this would work? Unless I did not describe the issue clearly enough. Thank you in advance!


Sub CheckDate()
Dim a, select1, from1, where1, As String

    Worksheets("Temporary").Activate
    Range("A3:IV65000").ClearContents
        
    select1 = "SELECT " & Worksheets("Generate Report").Range("B4") & " "
    from1 = "FROM " & Worksheets("Generate Report").Range("C4") & " "
    where1 = "WHERE " & Worksheets("Generate Report").Range("D4") & " "
    a = select1 & from1 & where1 & orderedBy
        
    Worksheets("Temporary").Activate
    Cells(2, 1).Select
        
    getData (a)
      
i = 3

    Do While (Cells(i, 1).Value <> "")
    
    difference = (DateDiff("d", Int(Cells(i, 9)), Int(Now())))
    
  '  difference2 = (DateDiff("d", Int(Cells(i, 10)), Int(Now())))

        If difference >= 30 And difference < 40 And Cells(i, 9) <> "" Then
            Cells(i, 13).Interior.Color = vbYellow
            Cells(i, 13).Font.Color = vbBlack
            Cells(i, 13) = "30 days warning"
        End If
        
        If difference >= 40 And difference < 45 And Cells(i, 9) <> "" Then
            Cells(i, 13).Interior.ColorIndex = 45
            Cells(i, 13).Font.Color = vbBlack
            Cells(i, 13) = "40 days warning"
        End If
        
       If difference > 45 And Cells(i, 9) <> "" Then
            Cells(i, 13).Interior.Color = vbRed
            Cells(i, 13).Font.Color = vbWhite
            Cells(i, 13) = "45 days warning"
        End If
          
        If difference < 30 Or Cells(i, 9) = "" Then
            Cells(i, 13).Interior.Color = vbWhite
        End If
    
    i = i + 1
    
    Loop    
    
End Sub