+ Reply to Thread
Results 1 to 4 of 4

how to Get all Strings Except last string in comma sepated string

  1. #1
    Registered User
    Join Date
    08-18-2014
    Location
    India
    MS-Off Ver
    2007
    Posts
    2

    how to Get all Strings Except last string in comma sepated string

    Hi Experts,

    I have list of addresses, which contains Address line1,Addr Line2(optional),Addr Line3(optional),Town,Postal Code.

    I want to extract all data except Postal Code.
    My Addresses are like

    5 Bridge Street, Wisbech, PE13 1AF
    81 High Street, Holbeach, Spalding, PE12 7ED
    The Old Vicarage, Capel Bangor, Aberystwyth, SY23 1LZ
    85 Uxbridge Road, London, W5 5TH
    Marringdean Road, Billingshurst, RH14 9HD

    i tried With
    =TRIM(LEFT(SUBSTITUTE(A1,",",REPT(" ",LEN(A1))),LEN(A1))) which returns only first text,
    and here no of commas are not fixed


    How can i do this ?

    Thanks
    Narasappa

  2. #2
    Forum Expert
    Join Date
    03-23-2004
    Location
    London, England
    MS-Off Ver
    Excel 2019
    Posts
    7,064

    Re: how to Get all Strings Except last string in comma sepated string

    Try
    =LEFT(TRIM(LEFT(A1,LEN(A1)-8)),LEN(TRIM(LEFT(A1,LEN(A1)-8)))-1)

    UPDATE: It'll will remove the last letter if the postcode is 6 characters, ie W5 5TH
    Last edited by Special-K; 08-20-2014 at 06:37 AM.
    Regards
    Special-K

    Ensure you describe your problem clearly, I have little time available to solve these problems and do not appreciate numerous changes to them.

  3. #3
    Forum Expert
    Join Date
    03-23-2004
    Location
    London, England
    MS-Off Ver
    Excel 2019
    Posts
    7,064

    Re: how to Get all Strings Except last string in comma sepated string

    This fixes the problem entirely.

    =LEFT(TRIM(LEFT(A1,LEN(A1)-8)),LEN(TRIM(LEFT(A1,LEN(A1)-8)))-IF(RIGHT(TRIM(LEFT(A1,LEN(A1)-8)),1)=",",1,0))

  4. #4
    Registered User
    Join Date
    08-18-2014
    Location
    India
    MS-Off Ver
    2007
    Posts
    2

    Re: how to Get all Strings Except last string in comma sepated string

    Many Thanks @ Special-K

+ 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] Adding comma to string
    By jharaldson in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-19-2014, 01:16 PM
  2. check to see if the first character in a string is a comma
    By pablowilks in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-19-2012, 03:52 PM
  3. How can I seperate numbers followed by a comma from a string
    By jaymullasseril in forum Excel General
    Replies: 2
    Last Post: 07-30-2011, 01:36 AM
  4. Comma separated string
    By ESF in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-20-2011, 06:39 AM
  5. Macro to find a comma in a string
    By Chuck in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 08-23-2005, 11:05 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