+ Reply to Thread
Results 1 to 13 of 13

Delete an entire line if row value found.

  1. #1
    Forum Contributor
    Join Date
    10-04-2014
    Location
    USA
    MS-Off Ver
    Office 365
    Posts
    161

    Delete an entire line if row value found.

    Looking for a macro that will delete an entire line if row value found on a separate tab.
    Example attached, thanks so much in advance.
    Attached Files Attached Files

  2. #2
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,659

    Re: Delete an entire line if row value found.

    Try this code

    PHP Code: 
    Option Explicit
    Sub deleteR
    ()
    Dim user As Rangecell As RangeAs Range
    With Sheets
    ("range")
        
    Set user = .Range("A1:A" & .Cells(Rows.Count"A").End(xlUp).Row)
    End With
    Sheets
    ("listing").Activate
    For Each cell In Range("B2:B" Cells(Rows.Count"B").End(xlUp).Row)
        If 
    WorksheetFunction.CountIf(usercellThen
            
    If U Is Nothing Then
                Set U 
    cell
            
    Else
                
    Set U Union(Ucell)
            
    End If
        
    End If
    Next
    If Not U Is Nothing Then U.EntireRow.Delete
    [A1].Select
    End Sub 
    Quang PT

  3. #3
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834

    Re: Delete an entire line if row value found.

    Good preparation for a simple AdvancedFilter.
    Please Login or Register  to view this content.

  4. #4
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 insider Version 2506 Win 11
    Posts
    24,785

    Re: Delete an entire line if row value found.

    An alternative with Power Query

    Please Login or Register  to view this content.
    Power Query is a free AddIn for Excel 2010 and 2013, and is built-in functionality from Excel 2016 onwards (where it is referred to as "Get & Transform Data").

    It is a powerful yet simple way of getting, changing and using data from a broad variety of sources, creating steps which may be easily repeated and refreshed. I strongly recommend learning how to use Power Query - it's among the most powerful functionalities of Excel.

    - Follow this link to learn how to install Power Query in Excel 2010 / 2013.

    - Follow this link for an introduction to Power Query functionality.

    - Follow this link for a video which demonstrates how to use Power Query code provided.
    Attached Files Attached Files
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  5. #5
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    14,964

    Re: Delete an entire line if row value found.

    Please Login or Register  to view this content.
    Good Luck...
    I don't presume to know what I am doing, however, just like you, I too started somewhere...
    One-day, One-problem at a time!!!
    If you feel I have helped, please click on the [★ Add Reputation] to left of post window...
    Also....Add a comment if you like!!!!
    And remember...Mark Thread as Solved...
    Excel Forum Rocks!!!

  6. #6
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834

    Re: Delete an entire line if row value found.

    Again....

    Only for the reason to reduce the code lines without adding proper error trap is the worst of all.

  7. #7
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    14,964

    Re: Delete an entire line if row value found.

    Understood...Am offering for supplied sample file based on availability of said values...Results are correct...
    Check your result...Is deleting "support1" too...

  8. #8
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834

    Re: Delete an entire line if row value found.

    Quote Originally Posted by sintek View Post
    Is deleting "support1" too...
    Please Login or Register  to view this content.

  9. #9
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    14,964

    Re: Delete an entire line if row value found.

    without adding proper error trap is the worst of all
    Noted...As per jindon...best is to incorporate if no matches found...
    Please Login or Register  to view this content.

  10. #10
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834

    Re: Delete an entire line if row value found.

    Not enough.

    Your code is based on the assumption of no blank cells in co.B.

    And what is the need of "IF(ROW)" close in formula?
    Last edited by jindon; 05-04-2024 at 09:37 AM.

  11. #11
    Forum Contributor
    Join Date
    10-04-2014
    Location
    USA
    MS-Off Ver
    Office 365
    Posts
    161

    Re: Delete an entire line if row value found.

    jindon, thanks so very much!!!!
    code works perfectly.

  12. #12
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834

    Re: Delete an entire line if row value found.

    You are welcome and thanks for the feedback.

    And thanks for the PM.

  13. #13
    Forum Expert
    Join Date
    11-28-2015
    Location
    indo
    MS-Off Ver
    2016 64 bitt
    Posts
    1,513

    Re: Delete an entire line if row value found.

    another ways
    Please Login or Register  to view this content.
    Last edited by daboho; 05-04-2024 at 11:37 AM.
    "Presh Star Who has help you *For Add Reputation!! And mark case as Solve"

+ 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. [SOLVED] VBA delete entire row if value not found in Listbox
    By Nastya621 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 06-01-2020, 06:55 AM
  2. Delete only selection instead of entire row if value found with VBA
    By ddasilva in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 04-18-2019, 04:58 PM
  3. Found?, then delete entire rows. Not found end sub
    By Andrewstupendo in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-21-2018, 01:56 PM
  4. [SOLVED] delete entire row when value is found
    By 9599lorenzo in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-14-2015, 03:06 AM
  5. [SOLVED] delete entire row when value is found
    By 9599lorenzo in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-13-2015, 06:47 PM
  6. [SOLVED] Delete Entire Row if Blank is Found in Column
    By EnigmaMatter in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 09-17-2014, 11:28 PM
  7. delete the entire row if duplicate found in column
    By gujugolf in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-15-2013, 04:07 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