Se houver conflito, aparecerá na coluna C, quando trocar de célula.
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim linha As Long
linha = 2
While ThisWorkbook.Sheets("Planilha1").Cells(linha, 1).Value <> ""
linha = linha + 1
Wend
Dim i, j As Long
For i = 2 To linha - 2
For j = i + 1 To linha - 1
Dim dtinicio, dtfinal, datainicio2, datafinal2 As Date
dtinicio = ThisWorkbook.Sheets("Planilha1").Cells(i, 1).Value
dtfinal = ThisWorkbook.Sheets("Planilha1").Cells(i, 2).Value
datainicio2 = ThisWorkbook.Sheets("Planilha1").Cells(j, 1).Value
datafinal2 = ThisWorkbook.Sheets("Planilha1").Cells(j, 2).Value
If datainicio2 <= dtfinal And datainicio2 >= dtinicio Then
ThisWorkbook.Sheets("Planilha1").Cells(j, 3).Value = "conflito"
End If
If datafinal2 <= dtfinal And datafinal2 >= dtinicio Then
ThisWorkbook.Sheets("Planilha1").Cells(j, 3).Value = "conflito"
End If
Next j
Next i
End Sub
Postado : 26/12/2017 11:53 am