Code:
Private Sub ListViewLaden()
Dim arrTab(), arrList(), i As Long, j As Long
If dynTab.DataBodyRange Is Nothing Then
ListView1.ListItems.Clear
Me.Width = (ListView1.Left * 2) + lvBreite + 27
Me.Height = 337
Exit Sub
End If
arrTab = dynTab.DataBodyRange.Value
ReDim arrList(1 To UBound(arrTab, 1), 1 To UBound(arrTab, 2) + 1)
For i = 1 To UBound(arrTab, 1)
For j = 2 To UBound(arrTab, 2) + 1
arrList(i, 1) = i
arrList(i, j) = arrTab(i, j - 1)
arrList(i, SpNrPLZ + 1) = Format(arrTab(i, SpNrPLZ), "00000")
Next j
arrList(i, 8) = Format(CDate(arrTab(i, 7)), "hh:mm")
Next i
With ListView1
ListView1.ListItems.Clear
.AllowColumnReorder = True
.Width = lvBreite + 13
For i = 1 To UBound(arrList, 1)
.ListItems.Add , , Format(arrList(i, 1), "00000")
For j = 2 To UBound(arrList, 2)
.ListItems(.ListItems.Count).SubItems(j - 1) = arrList(i, j)
Next j
If CDate(arrList(i, 8)) < CDate(Tabelle1.Cells(9, 10)) Then
.ListItems(.ListItems.Count).ListSubItems(1).ForeColor = RGB(255, 0, 0)
.ListItems(.ListItems.Count).ListSubItems(2).ForeColor = RGB(255, 0, 0)
End If
If CDate(arrList(i, 8)) > CDate(Tabelle1.Cells(9, 10)) And CDate(arrList(i, 8)) < CDate(Tabelle1.Cells(9, 12)) Then
.ListItems(.ListItems.Count).ListSubItems(1).ForeColor = RGB(205, 173, 0)
.ListItems(.ListItems.Count).ListSubItems(2).ForeColor = RGB(205, 173, 0)
End If
If CDate(arrList(i, 8)) > CDate(Tabelle1.Cells(9, 12)) Then
.ListItems(.ListItems.Count).ListSubItems(1).ForeColor = RGB(34, 139, 34)
.ListItems(.ListItems.Count).ListSubItems(2).ForeColor = RGB(34, 139, 34)
End If
Next i
.ListItems(1).Selected = False
.Font = "Arial"
.Font.Size = 10
End With
Me.Width = (ListView1.Left * 2) + lvBreite + 27
Me.Height = 337
End Sub
Den Link zum VBA Tanker Video habe ich nicht reingesetzt.