+ Reply to Thread
Results 1 to 3 of 3

How to delete row if value x is found in all three columns

Hybrid View

  1. #1
    Registered User
    Join Date
    08-21-2013
    Location
    Bonn, Germany
    MS-Off Ver
    Excel 2003
    Posts
    1

    How to delete row if value x is found in all three columns

    Hello
    I am looking for a makro that is deleting an entire row if the value x is in all three rows (A,C,E). I have a makro to delete row if the value x is found in one column, but it only should be deleted if found in all.

    Example.

    Row A C E
    6 text text x
    7 text text text
    8 x text x
    9 x x x <-- Makro should only delete this row
    10 text x text

    Help is much appreciated. This is the Makro is use to delete if value = x if it only matters for row A

    Sub Delete_value()

    Application.ScreenUpdating = False
    Sheets("test").Select
    Range("A8:A12").Select
    Do Until IsEmpty(ActiveCell.Value)
    If ActiveCell.Value = ("x") Then
    Selection.EntireRow.Delete
    Else
    ActiveCell.Offset(1, 0).Select
    End If
    Loop
    Application.ScreenUpdating = True

    End Sub

  2. #2
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: How to delete row if value x is found in all three columns

    Maybe
    Sub Delete_value()
    
    Dim cel As Range
    
    Application.ScreenUpdating = False
    Sheets("test").Select
    For Each cel In Range("A8:A12")
        If cel.value = "x" And Cells(cel.Row, 3).value = "x" And Cells(cel.Row, 5) = "x" Then
            cel.EntireRow.Delete
        End If
    next
    Application.ScreenUpdating = True
    
    End Sub
    Last edited by Solus Rankin; 08-27-2013 at 09:47 AM.
    Thanks,
    Solus


    Please remember the following:

    1. Use [code] code tags [/code]. It keeps posts clean, easy-to-read, and maintains VBA formatting.
    Highlight the code in your post and press the # button in the toolbar.
    2. Show appreciation to those who have helped you by clicking below their posts.
    3. If you are happy with a solution to your problem, mark the thread as [SOLVED] using the tools at the top.

    "Slow is smooth, smooth is fast."

  3. #3
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: How to delete row if value x is found in all three columns

    you could use something like
    Sub test()
    
        With Range("A2:E200")
        .AutoFilter
        .AutoFilter Field:=1, Criteria1:="x"
        .AutoFilter Field:=3, Criteria1:="x"
        .AutoFilter Field:=5, Criteria1:="x"
        .SpecialCells(xlCellTypeVisible).Select
        .EntireRow.Delete
        End With
        Range("a1").Select
    End Sub
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

+ 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. Use VBA loops to search for a list of values, delete columns they are found in
    By jfgay in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-25-2013, 07:58 AM
  2. [SOLVED] Delete Rows If value is found
    By Tortus in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-15-2013, 01:17 PM
  3. delete worksheet if found
    By mattfaust in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-30-2006, 11:33 AM
  4. [SOLVED] Re: Further help on delete criteria found
    By rjamison in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-13-2005, 08:05 PM
  5. [SOLVED] Further help on delete criteria found
    By Tempy in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 04-27-2005, 04:06 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