+ Reply to Thread
Results 1 to 4 of 4

Thread: Counting number of characters between 2 values in string

  1. #1
    Registered User
    Join Date
    01-25-2012
    Location
    ...
    MS-Off Ver
    Excel 2007
    Posts
    20

    Counting number of characters between 2 values in string

    I am trying to count characters between 2 "-"'s and another between a "-" and " " in a string. For example, the formula on "B-213-01 " should return 3 for the first part and returns 2 for the second.

    Regards,
    Last edited by ashraf999; 01-28-2012 at 03:29 AM.

  2. #2
    Forum Guru pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2010
    Posts
    5,150

    Re: Counting number of characters between 2 values in string

    Hi ashraf999
    to count between the -'s
    =LEN(TRIM(MID(SUBSTITUTE(B3,"-",REPT(" ",100)),100,100)))
    regards pike

    If the solution helped please donate
    here to the RSPCA

    Sites worth visiting;

    J&R Solutions - royUK

    AJP Excel Information - Andy Pope

    Spreadsheet Toolbox

    VBA for smarties - snb

  3. #3
    Forum Guru pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2010
    Posts
    5,150

    Re: Counting number of characters between 2 values in string

    ops the second part

    =LEN(TRIM(RIGHT(SUBSTITUTE(B3,"-",REPT(" ",100)),100)))
    regards pike

    If the solution helped please donate
    here to the RSPCA

    Sites worth visiting;

    J&R Solutions - royUK

    AJP Excel Information - Andy Pope

    Spreadsheet Toolbox

    VBA for smarties - snb

  4. #4
    Registered User
    Join Date
    01-25-2012
    Location
    ...
    MS-Off Ver
    Excel 2007
    Posts
    20

    Re: Counting number of characters between 2 values in string

    Thanks. Solved !

    Quote Originally Posted by pike View Post
    Hi ashraf999
    to count between the -'s
    =LEN(TRIM(MID(SUBSTITUTE(B3,"-",REPT(" ",100)),100,100)))

+ 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.2.0