+ Reply to Thread
Results 1 to 3 of 3

Row deletion

Hybrid View

  1. #1
    Registered User
    Join Date
    01-12-2011
    Location
    US
    MS-Off Ver
    Excel 2007
    Posts
    2

    Re: Row deletion

    Quote Originally Posted by TMShucks View Post
    Delete from the bottom up :-)

    For Cnt = 505 to 1 step -1

    You might need to adjust your logic ... maybe, step -5

    Regards
    Excellent, thank you. I didn't realize you could do that, maybe VB isn't so horrible after all.

    For anyone who is interested, this is the working code. (I hate googling & finding these posts with no solution posted at the end.)

    Sub Change()
        Dim Row As Integer
        Dim DeleteFlag As Integer
    
        DeleteFlag = 1
        
        For Row = 505 To 1 Step -1
            bgrange = "A" & Row & ":BB" & Row
    
            If DeleteFlag > 5 Then
                DeleteFlag = 1
            End If
    
            If DeleteFlag = 4 Or DeleteFlag = 5 Then
                DeleteFlag = DeleteFlag + 1
            Else
                DeleteFlag = DeleteFlag + 1
                'Cells(Row, 2).Value = DeleteFlag
                'Range(bgrange).Interior.Color = RGB(255, 0, 0)
                Range("A" & Row).EntireRow.Delete
            End If
        Next
    
    End Sub
    Last edited by mtfd; 01-13-2011 at 11:25 AM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1