Results 1 to 31 of 31

Delete Rows If C column has one of these words: apple, lemon, orange

Threaded View

  1. #1
    Forum Contributor aaaaa34's Avatar
    Join Date
    12-25-2013
    Location
    Istanbul
    MS-Off Ver
    Windows 10, MS Office 2013
    Posts
    375

    Delete Rows If C column has one of these words: apple, lemon, orange

    Hello my friends,
    I have this VBA code to do it which I obtained here earlier.
    Sub Column3DelRow(): Dim r As Long, n As Long, U As Range
    r = Cells(Rows.Count, 3).End(xlUp).Row
    For r = 1 To Cells(Rows.Count, 3).End(xlUp).Row
    If InStr(1, Cells(r, 3), "apple") Or InStr(1, Cells(r, 3), "lemon") Or InStr(1, Cells(r, 3), "orange") Then
    If U Is Nothing Then Set U = Cells(r, 3) _
    Else Set U = Union(Cells(r, 3), U)
    End If
    Next r
    If Not U Is Nothing Then U.EntireRow.Delete: Set U = Nothing
    End Sub
    Why it's If InStr(1, Cells(r, 3), "apple") ,not If InStr(2, Cells(r, 3), "apple")
    I ran the code as "2" and it didn't work.
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Data Validation - Apple|Orange|Pear
    By tmleynek in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 04-06-2016, 02:53 PM
  2. [SOLVED] VBA to delete rows where first 4 words of text in column A are duplicated
    By 1819 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-26-2016, 05:45 PM
  3. Delete rows if column A has more than X words
    By sami770 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-13-2015, 05:56 PM
  4. [SOLVED] A1 = Apple, B1 = Orange, C1 = Banana, i need answer at D1 = AOB (All first letter)
    By javaidmr in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 05-31-2014, 06:13 PM
  5. Find "apple" and "orange" in one search
    By HerryMarkowitz in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 04-15-2014, 10:38 AM
  6. Replies: 8
    Last Post: 03-08-2012, 02:06 PM
  7. Apple to Orange
    By MattShoreson in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-16-2005, 05:08 AM

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