Disclaimer: I have no idea what I am doing with VB; I work in the C family.
Currently we have excel workbooks in which specific rows need to be deleted (skip 2, delete 3).
I spaghetti'd this together and it seems to be working:
Sub Change()
Dim Cnt As Integer
Dim DeleteFlag As Integer
DeleteFlag = 1
For Cnt = 1 To 505
BgRange = "A" & Cnt & ":BB" & Cnt
If DeleteFlag = 5 Then
DeleteFlag = 1
Range(BgRange).Interior.Color = RGB(255, 0, 0)
'Range("A" & Cnt).EntireRow.Delete
Else
If DeleteFlag > 2 Then
Range(BgRange).Interior.Color = RGB(255, 0, 0)
'Range("A" & Cnt).EntireRow.Delete
End If
DeleteFlag = DeleteFlag + 1
End If
Next
End Sub
When run, this works as I want it to.
However, when flipping statement comments (eg, comment out the BG change and uncommenting the row deletion), it gives me wildly inaccurate deletions.
Anyone know what I am doing wrong?
Bookmarks