+ Reply to Thread
Results 1 to 2 of 2

nth instance of a character in a string

  1. #1
    Registered User
    Join Date
    07-20-2010
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    59

    nth instance of a character in a string

    Hi all,

    Looking for some help.

    I have a list of US addresses some of which contain a P.O. Box number with the "P" not necessarily in the first position. I am looking for some code to extract the PO Box and its associated number whioch may be any number of digits. I guess i can do this using the InStr function together with the Find function. Butt struggling. This is the kind of thing

    iStart = find( InStr(sString, " Box ")
    iEnd = InStr(sString, " Box ") + Find(......
    sNewString = Mid(sString, iStart, iEnd)


    iStart and iEnd are integer viariables. sString is the string that i'm examining and sNew String is the output e.g. "P.O. Box 2345" which is passed to an array for subsequent printing.

    Any help very much appreciated.

    Andrew

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: nth instance of a character in a string

    Andrew

    Can't you use InStr alone, first to find 'Box' then the space after it?
    If posting code please use code tags, see here.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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