Reading individual characters

  • Hello, I am trying to read in a text string located in a cell on my worksheet. This cell is formatted to contain text values, because I am inputting binary values ("0010").

    My problem is that I need to read each character of the string, one by one. How is it possible for my to check each digit?

    If anyone has any suggestions, it would be greatly appreciated!!!


  • Re: Reading individual characters

    If you are doing this in VBA, you can use the Left() and Right() functions
    For example:

    Left(MyString, 1) 'Will return the first char
    Right(Left(MyString, 2), 1) 'Will return the second char
    Right(Left(MyString, 3), 2) 'Will return the third
    Right(Left(MyString, 4), 3) 'Will return the fourth

    And so on..

    So, if you want to loop this:

    Dim I as Integer
    For I = 0 to MyString.Len
    MsgBox(Right(Left(MyString, I + 1), I))

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!