I'm trying to clean up a set of data and noticed something strange with vba function entirerow.delete The following code will, as intended, delete the entire row if it is in the format strikethrough, but will skip the rows immediately following it, if they are also in that format. It seems like a it takes a row that is not in the strikethrough format to "reset" the ability to delete more rows. Does anyone know why, or what I could do to debug this?
For Each rng In rng1
'Check each character in the cell
For i = 1 To Len(rng.Value)
'If any letter is Strikethrough,delete entire column
If rng.Characters(i, 1).Font.Strikethrough = True Then
rng.Select 'just serves the purpose of observing which rows are being selected
rng.EntireRow.Delete
GoTo NextRng
End If
Next i
NextRng:
Next rng
I should say that I have found a workaround using a different approach, but it is very slow:
'Delete cells that have the strikethrough format - works but is super slow!
ws2.Range("B2").Activate
Do Until ActiveCell.Value = ""
If ActiveCell.Font.Strikethrough = True Then
ActiveCell.EntireRow.Delete
Else: ActiveCell.Offset(1, 0).Activate
End If
Loop
If anyone has an alternative method to solve this issue that is also fast, I'd also be immensely grateful for your input.