+ Reply to Thread
Results 1 to 9 of 9

Utter macro (and forum) noob seeks string fragment matching macro help

  1. #1
    Registered User
    Join Date
    05-05-2015
    Location
    London
    MS-Off Ver
    Office for Mac: 2011
    Posts
    5

    Utter macro (and forum) noob seeks string fragment matching macro help

    Hello,

    I’m completely new to Excel macros and I’m hoping someone here might be kind enough to help me create a slightly fiddly one.

    I have a worksheet with several thousands of rows and many of these are essentially duplicates I want to get rid of. Basically, one column contains a string (just text) and within this string may or may not be the word “Fixed”. I need to see if that string contains “Fixed” (and I don’t even know if looking inside a string is possible) and if it does, I need to compare it with the same cell in the row below. If that cell also contains “Fixed”, I want to delete that second entire row. I then want to repeat the test. In other words, I want to keep the first row that has “Fixed” in the target cell but delete its duplicates.

    There’s a catch, natch. Once I’ve deleted all the duplicates of the first instance of "Fixed" (i.e. I come to a row that doesn’t match the row above when the strings are compared), I want to continue searching until I find another instance of the string. I then want to keep that instance but delete all its duplicates.

    I think the logic goes like this:

    1. Look in column C, row n (starting at row one)
    2. If column C is empty, stop
    3. Does cell contain the (sub)string “Fixed”?
    4. If cell doesn’t contain “Fixed”, move to row n+1 and repeat steps 2 onwards
    5. If cell does contain “Fixed”, repeat test on same cell in row below
    If this cell also contains “Fixed”
    Delete this entire row and move all remaining rows up (so no blank rows are created)
    If it doesn’t, repeat step 4 and continue

    This really isn't my forte and my investigations into macros have so far only hinted at parts of the solution. If your Kung Fu makes this task look trivially easy, I would be very grateful indeed for any assistance you can give me.

    Thank you for reading.

    A Knownowt

  2. #2
    Registered User
    Join Date
    12-16-2014
    Location
    Amsterdam, Nederland
    MS-Off Ver
    Excel 2013
    Posts
    71

    Re: Utter macro (and forum) noob seeks string fragment matching macro help

    Hi,

    There is in the menu Data, Remove duplicates.

    It just works without any programming.

    Bas

  3. #3
    Registered User
    Join Date
    05-05-2015
    Location
    London
    MS-Off Ver
    Office for Mac: 2011
    Posts
    5

    Re: Utter macro (and forum) noob seeks string fragment matching macro help

    Thank you for your swift reply. But wouldn't that result in my removing all duplicate values? I'm trying to remove duplicates in a range and then look for the beginning of the next range and delete all duplicates but the first, and so on.

    So
    F
    F
    F
    F

    Becomes

    F

    But

    F
    F
    F
    x
    x
    x
    F
    F
    F

    Becomes

    F
    x
    x
    x
    F

    And so on. Does the filtering mechanism you point to allow for this? (If it does, I'm afraid I've missed it but I'll be happy to roll up my sleeves if you're sure it does.)

    Thanks anyway for your help.

  4. #4
    Valued Forum Contributor
    Join Date
    11-12-2014
    Location
    Nottingham
    MS-Off Ver
    2013
    Posts
    383

    Re: Utter macro (and forum) noob seeks string fragment matching macro help

    What about this:

    Please Login or Register  to view this content.
    !If all your troubles are solved, then so is the thread. Show this by marking it so using thread tools at the top of the page.
    If I helped do this, then please show your appreciation by awarding rep points.
    <------ Button for that is over there

  5. #5
    Registered User
    Join Date
    05-05-2015
    Location
    London
    MS-Off Ver
    Office for Mac: 2011
    Posts
    5

    Re: Utter macro (and forum) noob seeks string fragment matching macro help

    ARowbot, I'll try that right now and post back. Thank you very much indeed.

  6. #6
    Forum Expert
    Join Date
    08-28-2014
    Location
    Texas, USA
    MS-Off Ver
    2016
    Posts
    1,796

    Re: Utter macro (and forum) noob seeks string fragment matching macro help

    Another approach:

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    05-05-2015
    Location
    London
    MS-Off Ver
    Office for Mac: 2011
    Posts
    5

    Re: Utter macro (and forum) noob seeks string fragment matching macro help

    Walruseggman, coo-ca-choo! Your routine did the business. ARowbot, Excel crashed when I ran your routine (but that's more likely something to do with my laptop than your code). I'm very grateful to you all for your helpfulness and wizardry. Thank you.

  8. #8
    Forum Expert
    Join Date
    08-28-2014
    Location
    Texas, USA
    MS-Off Ver
    2016
    Posts
    1,796

    Re: Utter macro (and forum) noob seeks string fragment matching macro help

    Glad to help.

    Please mark this thread as solved, and any reputation points (the * in the lower left of the posts) is appreciated.

  9. #9
    Registered User
    Join Date
    05-05-2015
    Location
    London
    MS-Off Ver
    Office for Mac: 2011
    Posts
    5

    Re: Utter macro (and forum) noob seeks string fragment matching macro help

    Done and done. Thanks again.

+ 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] Serch be fragment of text (Vloocup ? macro ?)
    By arn0ldas in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 02-06-2014, 08:17 AM
  2. [SOLVED] Vlookup - excel noob seeks excel wizard
    By Charlie.C in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 05-25-2013, 01:01 PM
  3. Replies: 2
    Last Post: 01-02-2013, 08:35 AM
  4. New to Forum- Grad Student Seeks Help with homework!
    By nmwaggoner in forum Hello..Introduce yourself
    Replies: 1
    Last Post: 11-23-2012, 01:27 PM
  5. [SOLVED] Newbie seeks suggestion on recording new macro to print sheets
    By Vivian in forum Excel - New Users/Basics
    Replies: 2
    Last Post: 05-10-2006, 02:00 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