+ Reply to Thread
Results 1 to 4 of 4

Left and right side of string?

  1. #1
    Registered User
    Join Date
    12-22-2004
    Posts
    7

    Left and right side of string?

    hey,

    I have a small problem that i do not know hot to solve, so pls help:

    Thats an example of my string:
    mystr = "Jz-9301NC-Ba + AU101TA"

    Now i need to get the left and the rigt side of mystr for example:

    mystrL = "Jz-9301NC-Ba"
    mystrR ="AU101TA"

    I know i could use left and right function if the my string would allways be the same, but its not. The only think that is allways the same ist " + " in the middle of mystr. So can someone pls help me out?

    Thx

  2. #2
    Forum Contributor
    Join Date
    06-10-2004
    Location
    India
    Posts
    1,066
    Consider your text is in cell A1, then for left use:
    =LEFT(A1,FIND(" + ",A1)-1)
    and for right, use:
    =RIGHT(A1,LEN(A1)-(FIND(" + ",A1)+2))

    Mangesh

  3. #3
    Registered User
    Join Date
    12-22-2004
    Posts
    7
    Thx, but i was asking for VBA not exell formula...

    I know that i can use find or search function in excell, but i dont know what to use in VBA?

  4. #4
    Forum Contributor
    Join Date
    06-10-2004
    Location
    India
    Posts
    1,066
    myStr = "Jz-9301NC-Ba + AU101TA"

    myPos = InStr(myStr, " + ")

    myLeft = Left(myStr, myPos - 1)
    myRight = Right(myStr, Len(myStr) - (myPos + 2))


    Mangesh

+ 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