0
I created this Sub
to process the data of my listview
. However, the first part of my If is not working properly: .ListViewEntradas.ListItems(i).ListSubItems(7) < Date
.
I would like to leave in red the records that have already passed the payment forecast - first condition - and that had not yet been carried out
- second condition. This way I need it to meet both conditions.
The problem is that if I put up the sign less than (<) he considers that all listview records match the condition. And when I put the sign greater than he considers that none correspond.
Sub PassouDaPrevisao()
Dim Colunas As Integer
Dim Linhas As Integer
'userform EntradasTeste
With EntradasTeste
Colunas = .ListViewEntradas.ColumnHeaders.Count
Linhas = .ListViewEntradas.ListItems.Count
For i = 1 To Linhas
'se a data de previsão for mais antiga que a data atual & se estiver marcada como não realizada
If .ListViewEntradas.ListItems(i).ListSubItems(7) < Date And .ListViewEntradas.ListItems(i).ListSubItems(8) <> "Realizado" Then
.ListViewEntradas.ListItems(i).ForeColor = RGB(255, 0, 0)
For X = 1 To Colunas - 1
.ListViewEntradas.ListItems(i).ListSubItems(X).ForeColor = RGB(255, 0, 0)
Next
End If
Next
End With
End Sub
What is the problem with my logic? And how can I solve?