Results 1 to 2 of 2

Thread: Spliting a String with no Delimiters

  1. #1

    Thread Starter
    New Member
    Join Date
    Dec 2009
    Posts
    1

    Spliting a String with no Delimiters

    Ok so im new to this forum and have not been in the VBA game for long so hopefully in my inexperience I have just missed the obvious. What I am trying to do is split a string of numbers into three different columns. The problem arises because their is no delimiters in the string

    an example of the string would be
    T010203

    and I need it split into three columns
    T01 02 03

    Any help would be greatly appreciated

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Spliting a String with no Delimiters

    Welcome to the forums.

    Presuming the string will always be the same length
    vb Code:
    1. Private Sub Command1_Click()
    2. Dim strString As String
    3. Dim strCol1 As String
    4. Dim strCol2 As String
    5. Dim strCol3 As String
    6.  
    7. strString = "T010203"
    8.  
    9. strCol1 = Left(strString, 3)
    10. strCol2 = Mid(strString, 4, 2)
    11. strCol3 = Right(strString, 2)
    12. MsgBox strCol1 & " " & strCol2 & " " & strCol3
    13. End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width