Closed Thread
Results 1 to 4 of 4

how to keep only the exact names of my list and delete the rest VBA macro excel

  1. #1
    Registered User
    Join Date
    02-23-2021
    Location
    france
    MS-Off Ver
    2010
    Posts
    17

    how to keep only the exact names of my list and delete the rest VBA macro excel

    Hello

    I have this script which work for my column A.

    Please Login or Register  to view this content.
    However i wanted to apply the same script for my excel file for column B i just changed by
    Please Login or Register  to view this content.
    , So is that i'd like delete now all components that are not in the list looking in my two columns A and B .
    For column A, it worked. i only have components that are part of my list however when i wanted to applied to column B it didn't work. I'd also like to keep only components that contain exactly the same word and not just part of the word. For example if in my list i have "methane" i'd like to keep only all components containing this exact word and not "sulfinysbismethane".



    Before applying the macro i have this
    TEST 6.PNG


    So basically i have in my list "chloro", "2,2,5-trimethylhexane" 2,2,4-trimethylpentante","water" and at the end i'd like to have this.

    test 7.PNG

    As you can see from the 3 pairs i'd like keep only "2,2,5-trimethylhexane" 2,2,4-trimethylpentante" as they are both on the list. Also for each component i'd like to keep its UTI and Reference as showed in the picture 2.

    I hope i was clear. Thank you for your help. Please find attached the excel file
    Attached Files Attached Files

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: how to keep only the exact names of my list and delete the rest VBA macro excel

    To test for exactly the same term, change this...
    Please Login or Register  to view this content.
    To this...
    Please Login or Register  to view this content.
    Or this to test column B as well...
    Please Login or Register  to view this content.
    If A and B match then the rows are not deleted. Change the And to OR if you want to delete only when both don't match
    Last edited by AlphaFrog; 03-04-2021 at 06:39 AM.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Registered User
    Join Date
    02-23-2021
    Location
    france
    MS-Off Ver
    2010
    Posts
    17

    Re: how to keep only the exact names of my list and delete the rest VBA macro excel

    Thank you very much!

    It works when i put "OR" but when i change it to "And' it deletes everything but the first components of my excel file, knowing that there were some components who were supposed to match both column A and B.

    Here is my script .
    Please Login or Register  to view this content.
    Thank you !
    Last edited by rosamoreno; 03-04-2021 at 11:29 AM.

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

    Re: how to keep only the exact names of my list and delete the rest VBA macro excel

    Administrative Note:

    Unfortunately, this is a duplicate thread, and you are allowed only ONE thread per issue here.

    See Forum Rule #5 about thread duplication.

    https://www.excelforum.com/excel-pro...cro-excel.html

Closed Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. how to keep only names of my list and delete the rest VBA macro excel
    By rosamoreno in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 03-04-2021, 07:25 AM
  2. Print all options from dropdown list to PDF and name the files the exact names in the list
    By johnwilliamboyle in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-17-2014, 11:49 AM
  3. [SOLVED] How to delete some data, but keep rest via macro
    By interested in forum Excel General
    Replies: 21
    Last Post: 10-30-2013, 01:19 PM
  4. Replies: 4
    Last Post: 08-28-2013, 11:02 AM
  5. Macro to filter certain values in a column and delete the rest
    By willy91785 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-25-2011, 12:23 PM
  6. Macro : To find word and Select rest after this cell and delete rest
    By Zortabello in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-08-2010, 08:06 AM
  7. [SOLVED] How do I alpha my mailing list in Microsoft excel and delete names
    By s janes in forum Excel - New Users/Basics
    Replies: 1
    Last Post: 11-02-2005, 06:20 PM

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