+ Reply to Thread
Results 1 to 11 of 11

delete entire row if not matched

  1. #1
    Forum Contributor
    Join Date
    05-10-2020
    Location
    india
    MS-Off Ver
    2013
    Posts
    221

    delete entire row if not matched

    Hi,
    I am looking for a macro that will do the things mentioned below
    If column I of 1.xls matches with column B of sheet2 of 2.xlsx then dont do anything & if not matched then delete entire row
    Plz see the sample file attached below
    Thnx


    Output of the macro will be
    in 1.xls the only 2 row will be there 25 & 100
    rest all data will be deleted in 1.xls
    macro will be placed in macro.xlsm
    all files are closed onl macro.xlsm is opened & all files are located in different place so the path will be hardcoded in the macro & i will edit it as per my requirement
    Attached Files Attached Files

  2. #2
    Valued Forum Contributor
    Join Date
    11-04-2018
    Location
    Denpasar
    MS-Off Ver
    Excel 2010
    Posts
    777

    Re: delete entire row if not matched

    Maybe something like this ?
    Please Login or Register  to view this content.
    The code assumes that those two workbooks are already open.
    It doesn't matter if the code resides in another workbook.

  3. #3
    Forum Contributor
    Join Date
    05-10-2020
    Location
    india
    MS-Off Ver
    2013
    Posts
    221

    Re: delete entire row if not matched

    Please Login or Register  to view this content.
    I modified the code as per my needs
    But getting error
    run time error 1004
    application defined or object defined error

    highlighted line
    Please Login or Register  to view this content.

  4. #4
    Valued Forum Contributor
    Join Date
    11-04-2018
    Location
    Denpasar
    MS-Off Ver
    Excel 2010
    Posts
    777

    Re: delete entire row if not matched

    Very sorry, my bad.
    I forget to put sh1. in the code .

    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    05-10-2020
    Location
    india
    MS-Off Ver
    2013
    Posts
    221

    Re: delete entire row if not matched

    Please Login or Register  to view this content.

    This code is not working i modified it as u mentioned but getting same error

  6. #6
    Valued Forum Contributor
    Join Date
    11-04-2018
    Location
    Denpasar
    MS-Off Ver
    Excel 2010
    Posts
    777

    Re: delete entire row if not matched

    2020-07-05_23-00-50.gif

    In my side, it doesn't throw me an error anymore in this line :
    Please Login or Register  to view this content.
    Yet, once again my bad and sorry for that, I forget to put . in this code :
    Please Login or Register  to view this content.
    as it should be like this:
    Please Login or Register  to view this content.

    Please Login or Register  to view this content.

  7. #7
    Forum Contributor
    Join Date
    05-10-2020
    Location
    india
    MS-Off Ver
    2013
    Posts
    221

    Re: delete entire row if not matched

    Please Login or Register  to view this content.

    Thnx For letting me know that i made a mistake
    Please Login or Register  to view this content.
    actually i corrected it
    Please Login or Register  to view this content.
    But Still i am getting issue

    Plz see the sample pic
    Attached Images Attached Images
    Last edited by dumdumbum; 07-05-2020 at 11:22 AM.

  8. #8
    Valued Forum Contributor
    Join Date
    11-04-2018
    Location
    Denpasar
    MS-Off Ver
    Excel 2010
    Posts
    777

    Re: delete entire row if not matched

    That's strange, because (as you can see in the animation where I put the code in Book3), at my side it doesn't throw me an error,

    Please try to check ... like this :
    Please Login or Register  to view this content.

  9. #9
    Forum Contributor
    Join Date
    05-10-2020
    Location
    india
    MS-Off Ver
    2013
    Posts
    221

    Re: delete entire row if not matched

    No Problem Karmapala
    i posted this question here https://eileenslounge.com/viewtopic.php?f=30&t=34920
    Thnx For helping me in solving this problem

  10. #10
    Forum Contributor
    Join Date
    05-10-2020
    Location
    india
    MS-Off Ver
    2013
    Posts
    221

    Re: delete entire row if not matched

    Please Login or Register  to view this content.
    Thnx Alot Karmapala for helping me in solving this problem
    little error was there & its been corrected
    Have a Great Day

  11. #11
    Valued Forum Contributor
    Join Date
    11-04-2018
    Location
    Denpasar
    MS-Off Ver
    Excel 2010
    Posts
    777

    Re: delete entire row if not matched

    Quote Originally Posted by dumdumbum View Post

    Thnx Alot Karmapala for helping me in solving this problem
    little error was there & its been corrected
    Have a Great Day
    It's difficult for me because I use Excel 2010 which has more rows count.
    Until before, I thought that just using the "Rows.Count", will work to every Excel version,
    but it turn out I need to define the sheet "sh1.Rows.Count" in order it work to every Excel version.

    Thanks for clarifying, dum.

    btw, I just noticed this in your code :
    Please Login or Register  to view this content.
    Since you define variable tt to c2.value,
    then I think better use it as follow :
    Please Login or Register  to view this content.
    Orrr....
    maybe you put that tt line just to check whether it gives a correct value or not .
    Last edited by karmapala; 07-05-2020 at 06:34 PM.

+ 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:Copy and Paste Entire Row of specific Part Number if it is matched into a New Workbook
    By tamprint in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 04-23-2018, 04:00 AM
  2. Search the value in multiple sheets and display the entire row of matched value in list bo
    By haridevadiga in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-26-2015, 08:08 AM
  3. [SOLVED] transfer every matched entrys entire to different-sheets (paste in cells)
    By marreco in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 11-05-2014, 11:42 AM
  4. [SOLVED] Transfer Every Matched Entry's Entire Row to a Different Sheet
    By RomanGriffen in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 09-04-2014, 09:52 AM
  5. Replies: 4
    Last Post: 12-04-2012, 04:45 PM
  6. [SOLVED] [How-to] ask marco to find, cut, paste entire row to new sheet if matched?
    By hark in forum Excel Programming / VBA / Macros
    Replies: 27
    Last Post: 11-15-2012, 01:55 AM
  7. [SOLVED] Retrieving the Entire Row of a Matched Value
    By marlea in forum Tips and Tutorials
    Replies: 1
    Last Post: 08-25-2005, 03:03 AM

Tags for this Thread

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