+ Reply to Thread
Results 1 to 8 of 8

Macro to filter out mismatched opposites. Dont look unless you want a challenge.. lol

  1. #1
    Registered User
    Join Date
    01-06-2012
    Location
    United States
    MS-Off Ver
    Excel 2003
    Posts
    26

    Macro to filter out mismatched opposites. Dont look unless you want a challenge.. lol

    I am trying to write a macro that copies the data from esoms.xls to esomsmacro.xls. It then compares A1 to B1. If they both contain " A" or " B" I want to delete the row. I have this much working. Next I need to see if the same 2 cells both have "A-" or "B-" and delete the row if they do. I think I was going about this the wrong way by deleting the rows that match my criteria rather than copy the rows to a new sheet when they have criteria that I am looking out for. If A1 has " A" and B1 has " B" then I think I should copy that to a new sheet. I need to do this for each row until I come to a blank row. Any help is greatly appreciated and Ill try my best to answer any questions.

    ex.
    A1 : MT -005- -MT B B1 : 1-MT -GRND -MTB EGRD0002 A

    because of the A and B not matching I need to keep these.

    here is what i started and started coming to some issues. I have made some of the code into comment to help in my troubleshooting. Thanks in advance:

    Please Login or Register  to view this content.
    Last edited by Leith Ross; 01-06-2012 at 04:51 PM. Reason: Added Code Tags

  2. #2
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Macro to filter out mismatched opposites. Dont look unless you want a challenge..

    Try this
    Please Login or Register  to view this content.
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  3. #3
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: Macro to filter out mismatched opposites. Dont look unless you want a challenge..

    hi saintsphan, welcome to ExcelForum, please amend your posted code as per Forum Rules, #3:
    http://www.excelforum.com/forum-rule...rum-rules.html

  4. #4
    Registered User
    Join Date
    01-06-2012
    Location
    United States
    MS-Off Ver
    Excel 2003
    Posts
    26

    Re: Macro to filter out mismatched opposites. Dont look unless you want a challenge..

    Quote Originally Posted by watersev View Post
    hi saintsphan, welcome to ExcelForum, please amend your posted code as per Forum Rules, #3:
    http://www.excelforum.com/forum-rule...rum-rules.html

    Sorry for that. Wont happen again

  5. #5
    Registered User
    Join Date
    01-06-2012
    Location
    United States
    MS-Off Ver
    Excel 2003
    Posts
    26

    Re: Macro to filter out mismatched opposites. Dont look unless you want a challenge..

    Mikerickson - Thank you for the incredibly quick response. Im not sure if I wasnt accurate in my information or if im posting your code in the wrong place but It dont seem to do anything at all when I run it. The files I have are too big to attach on here. Is there a way I can get them to you so you can better see what im trying to accomplish ?

    thanks again

  6. #6
    Registered User
    Join Date
    01-06-2012
    Location
    United States
    MS-Off Ver
    Excel 2003
    Posts
    26

    Re: Macro to filter out mismatched opposites. Dont look unless you want a challenge..

    I have made the 2 files shorter and uploaded them. Didnt think of that before but I hope that helps some.
    Attached Files Attached Files

  7. #7
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Macro to filter out mismatched opposites. Dont look unless you want a challenge..

    I cannot figure out what you are doing.
    You say that if both cells contain "A" that you want to delete them, but
    in esomsmacro, row one has
    4KV -001- -4KVESWGR 4A
    and
    1-4KV -CKTBRK-4KVEBKRTGB A8

    both of which have A.

    I don't understand.
    Could you make an example with some shorter, simpler data and fewer than the 2,000 rows in your attached workbooks.

  8. #8
    Registered User
    Join Date
    01-06-2012
    Location
    United States
    MS-Off Ver
    Excel 2003
    Posts
    26

    Re: Macro to filter out mismatched opposites. Dont look unless you want a challenge..

    I understand what you are saying.. Thats one of the issues I am having is that when they write these "A" they are not uniform. Ideally they would all be " A" or " B" but in the meantime I think I have been going about this all wrong. I am thinking it may be easier to find the " A" and " B" and "-A" "-B" and as it finds these then copy the row to a new sheet. Any suggestions or better ideas to do this is greatly appreciated.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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