+ Reply to Thread
Results 1 to 6 of 6

Loop through rows and delete based on criteria

Hybrid View

  1. #1
    Forum Guru benishiryo's Avatar
    Join Date
    03-25-2011
    Location
    Singapore
    MS-Off Ver
    Excel 2013
    Posts
    5,156

    Re: Loop through rows and delete based on criteria

    hi yolandraro30, welcome to the forum. try this:
    Sub test()
    
    Columns(1).Insert
    With Range("D2", Range("D" & Rows.Count).End(xlUp)).Offset(, -3)
        .Formula = "=COUNTIF($D$2:D2,D2)"
        .Value = .Value
    End With
    For v = Range("A" & Rows.Count).End(xlUp).Row To 2 Step -1
        If Cells(v, 1) > 10 Then
            Rows(v).Delete
        End If
    Next v
    Columns(1).Delete
    
    End Sub

    Thanks, if you have clicked on the * and added our rep.

    If you're satisfied with the answer, click Thread Tools above your first post, select "Mark your thread as Solved".

    "Contentment is not the fulfillment of what you want, but the realization of what you already have."


    Tips & Tutorials I Compiled | How to Get Quick & Good Answers

  2. #2
    Registered User
    Join Date
    12-18-2012
    Location
    illinois
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Loop through rows and delete based on criteria

    Thank u so much. This worked perfectly!!!

  3. #3
    Registered User
    Join Date
    12-18-2012
    Location
    illinois
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Loop through rows and delete based on criteria

    As I mentioned i'm a novice, so I'm still trying to understand. I understand the first for loop, but can you breakdown the second one for me. especially the part with "2 Step - 1". Thanks again for taking your time to help with this.

+ 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