Deleted Flag Rows

Sub DeleteRowIfMarked()
‘If the first cell has a ‘x’ in it, then the row will be deleted.  The process will stop when the first cell in the row is blank
Dim iStartRow As Integer, iSections As Integer, iCounter As Integer
    Dim bEndMe As Boolean, bOneRemoved As Boolean
    Dim sRange As String
    Dim sRange2 As String

    bEndMe = False
iStartRow = 2

    Do
sRange = “A” & CStr(iStartRow)
        bOneRemoved = False
        
        If Range(sRange).Value = “x” Then
            sRange = CStr(iStartRow)
            Rows(sRange).Select
            Selection.Delete Shift:=xlUp
            bOneRemoved = True
        End If
        sRange = “A” & CStr(iStartRow)
        If Range(sRange).Value = “” Then bEndMe = True
        
        If bOneRemoved = False Then
            iStartRow = iStartRow + 1
        Else
            ‘The row was deleted so do not increment
            iStartRow = iStartRow
        End If
    Loop Until bEndMe = True
End Sub
 

Leave a Reply