+ Reply to Thread
Results 1 to 3 of 3

How to search substring against row and if duplicates found, remove them?

  1. #1
    Registered User
    Join Date
    09-03-2016
    Location
    ST louis, missouri, usa
    MS-Off Ver
    2013
    Posts
    2

    How to search substring against row and if duplicates found, remove them?

    Desired logic:
    If O2="true" then search (substrings) in e2 against e:e and if (substrings) in e2 are found elsewhere in e:e then delete said substrings from e2, else do nothing, leave cell contents as is.

    e2 looks like:

    http:// ec2-54-172-158-94.compute-1.amazonaws.com/assets/images/bob/asdf1.jpg;http:// ec2-54-172-158-94.compute-1.amazonaws.com/assets/images/bob/asdf2.jpg;http:// ec2-54-172-158-94.compute-1.amazonaws.com/assets/images/bob/asdf3.jpg

    I have inserted spaces after the // to preserve formatting. The semicolon ";" separates substrings. In this case, e2 has the three unique substrings of:

    http:// ec2-54-172-158-94.compute-1.amazonaws.com/assets/images/bob/asdf1.jpg

    http:// ec2-54-172-158-94.compute-1.amazonaws.com/assets/images/bob/asdf2.jpg

    http:// ec2-54-172-158-94.compute-1.amazonaws.com/assets/images/bob/asdf3.jpg

    What I do know:
    1 The amount of substrings in each cell in range e:e are not guaranteed to be the same. Cells may sometimes be blank but will never exceed 12 substrings.
    2)Substrings will ALWAYS start with the http:// file path up UNTIL the word "bob".

    Ask any questions! Thanks! I asked over on mrexcel and couldn't find an answer. I googled but my knowledge of vba isn't sufficient.
    Last edited by joshman10888; 09-03-2016 at 07:50 PM.

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

    Re: How to search substring against row and if duplicates found, remove them?

    Could you attach a workbook showing some representative data and desired results?

    If I read your question correctly, you want this macro to act on E2 only and not change the contents of the other rows of E.

    The if O2=True is a bit puzzling. Are you looking for this macro to be triggered by the user entering True in O2, or are you looking for a spreadsheet formula that will return the reduced value from E2 into some other cell? Something like =IF(O2, reduced(E2), E2)
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  3. #3
    Registered User
    Join Date
    09-03-2016
    Location
    ST louis, missouri, usa
    MS-Off Ver
    2013
    Posts
    2
    Quote Originally Posted by mikerickson View Post
    Could you attach a workbook showing some representative data and desired results?

    If I read your question correctly, you want this macro to act on E2 only and not change the contents of the other rows of E.

    The if O2=True is a bit puzzling. Are you looking for this macro to be triggered by the user entering True in O2, or are you looking for a spreadsheet formula that will return the reduced value from E2 into some other cell? Something like =IF(O2, reduced(E2), E2)
    Im out right now so i cant attach sorry. Yes I should clarify. Basically there are cells in the E:E range that contain duplicate substrings. So for instance there might be duplicates in e2 and e4 but I have identified which of the cells ought to have the duplicates deleted by marking the associated O cell as TRUE. The range might be several thousand rows and any may contain duplicates that need to be removed. So e192 may have duplicates that are in e1356. We know which cell to target for deletion by looking at the O values for those rows. If O1356 is marked true then the duplicates found in the corresponding e1356 ought to be removed and e192 should stay.

    So every cell in range E is subject to be searched for duplicates against the range and removed if the associated O value is true. Hope that makes sense.

+ 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 values and remove all duplicates
    By CJBeaty in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-25-2016, 02:22 PM
  2. remove duplicates based on name found in column b
    By antiKILLER in forum Excel General
    Replies: 2
    Last Post: 03-01-2016, 02:57 PM
  3. Macro to search cells for substring and replace contents of cell if substring is found
    By robbyvegas in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-31-2015, 06:40 AM
  4. [SOLVED] Remove duplicates and search last 2 digits only
    By MIFF3436 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-17-2014, 06:02 PM
  5. Remove cells if duplicates found
    By garnerseo in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 10-18-2013, 08:54 AM
  6. Search substring within range, report the substring found
    By Brooke1578 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 12-20-2012, 03:56 PM
  7. Splitting a row into two when a certain substring is found
    By lifeseeker1019 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-17-2011, 11:32 PM

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