+ Reply to Thread
Results 1 to 13 of 13

search code in other sheet and if found delete full row

  1. #1
    Forum Contributor
    Join Date
    10-30-2019
    Location
    GUJARAT,INDIA
    MS-Off Ver
    MS OFFICE 2016
    Posts
    235

    search code in other sheet and if found delete full row

    I have few code numbers written in sheet1 col. A
    I want code that can 1) search for code written in sheet1 col. A in sheet2 Col.A
    and if found delete full row from sheet2.
    Request members of this forum to guide me
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow Re: search code in other sheet and if found delete full row


    As your expected result does not match your explanation …

    Anyway you can try an easy Excel basics like an advanced filter in order to filter the rows to be deleted
    like any Excel beginner operating manually so without the need of any VBA procedure …
    Last edited by Marc L; 03-12-2022 at 07:11 AM.

  3. #3
    Forum Contributor
    Join Date
    10-30-2019
    Location
    GUJARAT,INDIA
    MS-Off Ver
    MS OFFICE 2016
    Posts
    235

    Re: search code in other sheet and if found delete full row

    I want to delete rows in one click(i,e, using macro)
    I don't want to delete rows one by one.
    please guide.

  4. #4
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow Re: search code in other sheet and if found delete full row


    As your expected result does not match your explanation …

    And my previous post is just about deleting all filtered rows at once like any Excel user can operate easily without any VBA procedure !
    Last edited by Marc L; 03-12-2022 at 07:11 AM.

  5. #5
    Forum Contributor
    Join Date
    10-30-2019
    Location
    GUJARAT,INDIA
    MS-Off Ver
    MS OFFICE 2016
    Posts
    235

    Re: search code in other sheet and if found delete full row

    by mistake I have written sheet 1 instead of sheet2 and sheet2 instead of sheet1 of sheet1 in my question.
    sorry for inconvenience.
    Please guide.

  6. #6
    Forum Contributor
    Join Date
    10-30-2019
    Location
    GUJARAT,INDIA
    MS-Off Ver
    MS OFFICE 2016
    Posts
    235

    Re: search code in other sheet and if found delete full row

    can someone help

  7. #7
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow Re: search code in other sheet and if found delete full row


    Did you give it a try at least to the Excel basics easy advanced filter ? Should be achieved in around ten seconds,
    so faster than creating a thread on any forum and faster than creating a procedure …
    If a VBA procedure is really necessary just activating the Macro Recorder before operating in order to get your own code base.

    As your expected result does not exactly match your explanation
    so it will be such a good idea to post an attachment - saved as .xlsb - without any error in the expected result at least …
    Last edited by Marc L; 03-12-2022 at 07:28 AM.

  8. #8
    Forum Contributor
    Join Date
    10-30-2019
    Location
    GUJARAT,INDIA
    MS-Off Ver
    MS OFFICE 2016
    Posts
    235

    Re: search code in other sheet and if found delete full row

    I have few code numbers written in sheet2 col. A
    I want code that can 1) search for code written in sheet2 col. A in sheet1 Col.A
    and if found delete full row from sheet1.
    Request members of this forum to guide me
    (Reason why I want to use macro is that there are many supporting macros and excel formulas used in excel work book. Sheet1 contains
    basis input data for all supporting macros and VLOOKUP formulas I want above mentioned macro to update basic input data
    in sheet1 by deleting matching codes. so that other supporting macros can give updated output. attached file is just a samplefile for creating
    macro mentioned above only)
    Attached Files Attached Files

  9. #9
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: search code in other sheet and if found delete full row

    See if the attached works for you
    Attached Files Attached Files

  10. #10
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow Re: search code in other sheet and if found delete full row


    As a reminder according to the Excel basics advanced filter and the Macro Recorder less than ten codelines is necessary …

  11. #11
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Cool Try the kid Excel beginner way !


    So just operating manually an advanced filter less than 10 seconds is necessary to delete the filtered rows at once,
    the reason why I never had the need to create any VBA procedure for such easy and basic operation …
    When a procedure is really necessary - never met the case - so just activating the Macro Recorder to get a good starting point …

    According to post #8 attachment for starters :

    PHP Code: 
    Sub Macro1()
        
    With [Sheet1!A1].CurrentRegion.Rows
           
    .AdvancedFilter 1, [Sheet2!A1].CurrentRegion.Columns(1)
            If 
    Application.Subtotal(103, .Columns(1)) > 1 Then .Item("2:" & .Count).Delete xlShiftUp
           
    .Parent.ShowAllData
        End With
    End Sub 
    ► Do you like it ? ► So thanks to click on bottom left star icon « Add Reputation » !

  12. #12
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow As I forgot to mention …


    In addition how to know if a VBA procedure is good enough ?

    Run it, check the result and if it is the expected one, run a second time the same VBA procedure even if it's not needed,
    the result must be the same without any error message …

  13. #13
    Forum Contributor
    Join Date
    10-30-2019
    Location
    GUJARAT,INDIA
    MS-Off Ver
    MS OFFICE 2016
    Posts
    235

    Re: search code in other sheet and if found delete full row

    @AB33 : Thanks. with few modifications your code is giving desired results. I am happy that you have solved my problem in just one reply.

+ 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] search of specified word in excel sheet cells and paste full row on next sheet
    By kv.singh in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 12-13-2020, 05:23 AM
  2. Code to search for items, copy to different sheet and delete them
    By pemb3545 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 01-30-2014, 10:45 AM
  3. [SOLVED] Macro ignores search code when 1 of the 2 search parameters is not found
    By BrodyNoochie in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-25-2012, 05:21 PM
  4. VB A to loop to search through a list and delete a record if found
    By 4am in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-25-2011, 10:26 AM
  5. VBA Delete Code not running in full program
    By WasWodge in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-04-2010, 12:04 AM
  6. Search cell (external book) and delete row if found
    By Zaeguzah in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 09-22-2009, 03:47 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