Results 1 to 26 of 26

How to get substring in a major string with VBA

Threaded View

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

    How to get substring in a major string with VBA

    Hi

    I have a few sample strings like bellow:


    1: "in-Training and Development Officer Pakistan"
    2: "Training and Development Officer Pakistan-in"
    3: "Training and Development Officer in-Pakistan"
    4: "Training and Development Officer in Pakistan"


    remember these are the samples

    What I would like to get is the word "in" in the major string
    If I use instr or instrRev functions they pic in that is in "training"
    What my logic is (You may have your own which I would like to know also) if the character on the right other than the substring and left of that substring other than the substring is non alpha then that is my word.else not

    like ain ,in is not myword as it has alpha character on the left
    like inin ,in is also not my word as it also have a alpha on the right
    but " in-" , here in is my word

    How can I pass the main string from this logic in VBA

    Help would be greatly appreciated

    Best Regards
    Imran Bhatti

    Hope that makes sense.
    Imran Bhatti
    Last edited by ImranBhatti; 12-14-2017 at 08:08 AM.
    Teach me Excel VBA

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Need help in extracting substring from string
    By juixyy in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 01-14-2016, 05:28 AM
  2. [SOLVED] Copy a substring from a string
    By raul09 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 04-02-2013, 12:53 AM
  3. Finding a substring within a string
    By Michael D in forum Excel General
    Replies: 7
    Last Post: 02-21-2013, 04:01 PM
  4. [SOLVED] extract from string whole word(s) containing substring
    By Bearpecs in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 09-24-2012, 10:37 AM
  5. Searching for a substring in a string
    By 1rovilla in forum Excel General
    Replies: 3
    Last Post: 05-07-2010, 08:17 PM
  6. Substring based on position in string
    By yellephant in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-14-2007, 10:12 AM
  7. [SOLVED] check substring of a string in Excel VBA
    By magix in forum Excel General
    Replies: 2
    Last Post: 12-11-2005, 11:10 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