+ Reply to Thread
Results 1 to 4 of 4

Excluding item in array?

  1. #1
    Forum Contributor
    Join Date
    07-08-2008
    Location
    New York City
    MS-Off Ver
    2013-2016
    Posts
    157

    Excluding item in array?

    Hello,

    I have a tricky question. Is there a way to loop through a string array but not include one of it's items?

    I'm comparing each word in the array against a string with two or more words. The thing is, I know one of the words in the array will be in the string.
    I would like to know if a second word is found in the string. This is what I have:

    Please Login or Register  to view this content.
    If I run it the way it is, it will always find a match. I need to find the second match...

    Hope I was clear enough. Any help will be appreciated. Thanks.

  2. #2
    Forum Guru
    Join Date
    04-23-2012
    Location
    New Jersey, USA
    MS-Off Ver
    Excel 365
    Posts
    2,410

    Re: Excluding item in array?

    If I understand what you want correctly, you are running the test backwards. Split the contents of cell D3 and the using InStr to see if each word is in cell A3's text. If the InStr test ever returns 0, that word is not in cell A3 so you can exit the Sub or do whatever you want when that happens. If you make it through the entire loop without hitting 0, all the words in cell D3 are in the text of cell A3.

  3. #3
    Forum Contributor
    Join Date
    07-08-2008
    Location
    New York City
    MS-Off Ver
    2013-2016
    Posts
    157

    Re: Excluding item in array?

    Makes sense. I'll try that. Thank you!

  4. #4
    Registered User
    Join Date
    03-10-2021
    Location
    Paryzevo
    MS-Off Ver
    2k3
    Posts
    60

    Re: Excluding item in array?

    Quote Originally Posted by DMA View Post
    ... If I run it the way it is, it will always find a match ...
    ???
    Everyone's imagination is slightly different from the rest - please provide a small example with the input data and the expected result.

+ 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] Loop is not triggered when using an array if first item in array is not found
    By Ianmacros in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-26-2019, 01:35 PM
  2. Return minimum value excluding zero - Non array help
    By MXSYYC in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 05-23-2019, 01:28 PM
  3. [SOLVED] Sum array excluding #N/A
    By BC TIPPING in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 10-09-2017, 12:27 AM
  4. Excluding Cells From an Array!
    By AstToTheRegionalMGR in forum Excel General
    Replies: 6
    Last Post: 12-15-2014, 04:13 PM
  5. [SOLVED] If dictionary key exists add new item to existing item array
    By strud in forum Excel Programming / VBA / Macros
    Replies: 18
    Last Post: 11-25-2014, 01:54 PM
  6. Sumproduct excluding an Array
    By Odysseus in forum Excel General
    Replies: 4
    Last Post: 12-16-2009, 12:42 PM
  7. Most frequent item in a list (excluding zeros)
    By Andre Croteau in forum Excel General
    Replies: 3
    Last Post: 11-12-2005, 03:10 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