• Getting the first Character of a String (2000)

    Home » Forums » AskWoody support » Productivity software by function » MS Excel and spreadsheet help » Getting the first Character of a String (2000)

    Author
    Topic
    #361650

    Thanks for your help on my Range() dilemma. Now a (hopefully) easy question:

    How do I truncate a string to get only the first character?

    For example, I want the string

    1. John Doe

    to become

    1

    Viewing 2 reply threads
    Author
    Replies
    • #547323

      enter the following formula in the desired cell.
      =LEFT(A1,1)

      A1 is the cell with the data you would like to hack and 1 being the character to leave intact.

      or with VBA you could try Range(“A1″) .Formula =”=LEFT(Cell,1)”

    • #547324

      If your string is in A1, then =Left(A1,1) should work.

      In VBA you can use a similar construct with Left(strExpression,1) where strExpression is the string you wnat to work with.

      Andrew C

    • #547325

      The cell formula is =left(string,num_of_characters) to return a string starting from the left.
      e.g. LEFT(“Hello world”,1) returns “H”
      LEFT(“Hello world”,3) returns “Hel”
      If num_of_characters is omitted it is assumed to be 1.

      The VBA formula is the same but if the number is omitted you get a zero length string, “”

      Ewan.

    Viewing 2 reply threads
    Reply To: Getting the first Character of a String (2000)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: