ich habe kürzlich eine Praktikumstelle angefangen und stehe leider jetzt schon vor einem Problem bei einer Arbeit:
Ich möchte in einem Excel Dokument Zeilen löschen, in denen Text mit dunkelroter Farbe (in Spalte D) steht (dunkelrot = Farbindex 9)
Leider habe ich kaum VBA in Excel Kenntnisse - trotzdem habe ich 2 Ansätze, die leider nicht funktionieren:
Ansatz 1 (Idee: egal in welcher Spalte der dunkelrote Text steht -> Zeile löschen)
Sub DeleteRow()
Dim intRow As Integer, intLastRow As Integer
intLastRow = Cells.SpecialCells(xlCellTypeLastCell).Row
For intRow = intLastRow To 1 Step -1
If Font.ColorIndex(Rows(intRow)) = 9 Then
Rows(intRow).Delete
End If
Next intRow
End Sub
Ansatz 2 (wenn dunkelroter Text in Spalte D steht -> Zeile löschen)
Sub DeleteRowD()
Dim intRow As Integer, intLastRow As Integer
intLastRow = Cells.SpecialCells(xlCellTypeLastCell).Row
For intRow = intLastRow To 1 Step -1
If Application.CountA(Rows(intRow)) = 0 Then
intLastRow = intLastRow - 1
Else
Exit For
End If
Next intRow
For intRow = intLastRow To 1 Step -1
If Format.ColorIndex(Cells(intRow, 4)) = 9 Then
Rows(intRow).Delete
End If
Next intRow
End Sub
Zu 90% bin ich mir sicher, das der Fehler in der Spalte Font.ColorIndex(Rows(intRow)) = 9 liegt, leider weiss ich - aufgrund meiner wenigen VBA in Excel Erfahrung - nicht warum.
Es wäre nett wenn mir jmd helfen könnte. Danke im Voraus.