+ Reply to Thread
Results 1 to 5 of 5

Delete Rows in Excel Using VBA Based on Condition

Hybrid View

  1. #1
    Registered User
    Join Date
    03-18-2015
    Location
    Vietnam
    MS-Off Ver
    2013
    Posts
    14

    Delete Rows in Excel Using VBA Based on Condition

    Hi everyone,

    I want to delete rows that have the text TRUE in column I, by using VBA. But I haven't figured it out. Is there any clues for this problem?
    Thanks for your reading!

  2. #2
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: Delete Rows in Excel Using VBA Based on Condition

    Perhaps

    Sub test()
    Dim LR As Long, i As Long
    LR = Cells.Find(What:="*", SearchDirection:=xlPrevious, SearchOrder:=xlByRows).Row
    For i = LR To 1 Step -1
        If LCase(Range("I" & i).Value) = "TRUE" Then Rows(i).Delete
    Next i
    End Sub
    Regards

    Fotis.

    -This is my Greek whisper to Europe.

    --Remember, saying thanks only takes a second or two. Click the little star * below, to give some Rep if you think an answer deserves it.

    Advanced Excel Techniques: http://excelxor.com/

    --KISS(Keep it simple Stupid)

    --Bring them back.

    ---See about Acropolis of Athens.

    --Visit Greece.

  3. #3
    Registered User
    Join Date
    03-18-2015
    Location
    Vietnam
    MS-Off Ver
    2013
    Posts
    14

    Re: Delete Rows in Excel Using VBA Based on Condition

    @Fotis1991: It doesn't work, but thanks for your reply

    @JOHN H. DAVIS: I've tried it and it is great. Thanks for your help!

  4. #4
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Delete Rows in Excel Using VBA Based on Condition

    Maybe:

    Sub mayaincaztec()
    Range("I1:I" & Range("I" & Rows.Count).End(3).Row).AutoFilter 1, "TRUE"
    Range("I2:I" & Range("I" & Rows.Count).End(3).Row).SpecialCells(12).EntireRow.Delete
    ActiveSheet.AutoFilterMode = False
    End Sub

  5. #5
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Delete Rows in Excel Using VBA Based on Condition

    You're welcome. Glad to help out and thanks for the feedback.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Delete rows based on more than one condition
    By Steve2107 in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 04-16-2014, 06:16 AM
  2. Macro to delete all rows based on one condition
    By vemix in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 10-30-2012, 05:24 AM
  3. Delete rows based on condition
    By elocin17 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-12-2012, 12:35 PM
  4. Delete rows based on a condition
    By sakinen in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 07-20-2009, 09:14 AM
  5. A loop to delete rows based on condition
    By Josh_123456 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-21-2007, 05:51 PM

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