+ Reply to Thread
Results 1 to 4 of 4

Determining if a sub string is a complete word

  1. #1
    Valued Forum Contributor ImranBhatti's Avatar
    Join Date
    03-27-2014
    Location
    Rawalpindi,Pakistan
    MS-Off Ver
    Office 365
    Posts
    1,784

    Determining if a sub string is a complete word

    Hi,

    An example of my string is
    "Microsoft Office Specialist"

    Want to determine

    1: if it is the last substring in the main string?
    if yes then
    a:if the character just before "Office Specialist" (in this case) is a non alpha? (like a space in this case)
    if 1 is No then
    a:the character before and after this sub string are both non alpha.

    So that I can extract it as my "Wanted substring"

    Hope this makes sense.
    Teach me Excel VBA

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Determining if a sub string is a complete word

    Hello ImranBhatti,

    If you have a string (substring) you want too find in another string (main string) and extract the substring then there are several options. Which option to use depends on where this string is located, where the result will be returned to and the rules to extract the substring.

    If you could provide a few before and after examples, it would be a great help. If you have a workbook you can post, that would be even better.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

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

    Re: Determining if a sub string is a complete word

    Here is a function (can be used as a UDF - user defined function if desired) that locates the position of the exact word (that is, a word that is not embedded within a larger word) in a given text string which I think you can make use of. If the exact word does not exist within the text, then the function returns 0 for its position.
    Please Login or Register  to view this content.
    The function has two required arguments and two optional arguments... the first argument is the main text to search, the second argument is the exact word (or phrase) to look for, the third argument is optional and sets the starting position in the main text to begin searching from (the default starting position if the argument is omitted is 1) and the fourth argument, also optional, is a Boolean (True or False) for whether the search is case sensitive or not (the default if it is omitted is False meaning the search is case insensitive).
    Last edited by Rick Rothstein; 08-18-2019 at 12:51 AM.

  4. #4
    Valued Forum Contributor ImranBhatti's Avatar
    Join Date
    03-27-2014
    Location
    Rawalpindi,Pakistan
    MS-Off Ver
    Office 365
    Posts
    1,784

    Re: Determining if a sub string is a complete word

    Hi Rick Thanks for the review and solution

    It is working as expected

    Thanks to all for trying to help

+ 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. Replies: 3
    Last Post: 03-29-2023, 07:18 AM
  2. Replies: 14
    Last Post: 04-21-2017, 04:56 PM
  3. [SOLVED] Grab last word from string and then delete word from original string.
    By mtilbury in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 09-14-2015, 04:14 AM
  4. [SOLVED] determining if cell text string is multicoloured and change.
    By Kramxel in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-08-2015, 12:22 PM
  5. [SOLVED] How to place a value in one cell after determining if a string of cells contain a number?
    By vnetmanager in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 01-25-2013, 02:35 PM
  6. [SOLVED] determining bold font in a string
    By william kossack in forum Excel General
    Replies: 2
    Last Post: 11-02-2005, 06:17 PM
  7. Determining A Cell If it contain A string value
    By Rob in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 08-26-2005, 11:05 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