Results 1 to 5 of 5

Thread: Excel VB Textobxes Characters
Thanks Thanks: 0 Likes Likes: 0

  1. #1
    New Member
    Join Date
    Dec 2016
    Posts
    49
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Post Excel VB Textobxes Characters

    Hi Excel Gurus,

    I nee a help on a cod to separate Texts at Textboxes.

    So I have here TextBoxComments, TextBoxA, TextBoxB, and TextBoxC.

    So the TextBoxComments is where the user would place the comments on the file.

    What I want to do is whenever the TexBoxComments reaches its first 255 characters, it will go to TextBoxA, the next succeeding 255 characters will go to TextBoxB and the last succeeding 255 characters will go to TextBoxC.

  2. #2
    Board Regular
    Join Date
    Mar 2015
    Posts
    4,055
    Post Thanks / Like
    Mentioned
    73 Post(s)
    Tagged
    8 Thread(s)

    Default Re: Excel VB Textobxes Characters

    Enter all text in TextBoxComments and then run the code

    Code below written for active-x textboxes embedded in a worksheet
    Code simplified to make it easy to follow
    Place code in SHEET module (not Module1, Module2 etc)

    Code:
    Sub Trans()
        Dim c As String
        c = TextBoxComments.Text
        
        TextBoxComments = Left(c, 255)
        TextBoxA = Mid(c, 255 + 1, 255)
        TextBoxB = Mid(c, 255 + 255 + 1, 255)
        TextBoxC = Mid(c, 255 + 255 + 255 + 1, 255)
    End Sub

    EDIT
    Did I misread your request? Is it this you want?

    Code:
    Sub Trans()
        Dim c As String
        c = TextBoxComments.Text
        
        TextBoxComments = ""
        TextBoxA = Left(c, 255)
        TextBoxB = Mid(c, 255 + 1, 255)
        TextBoxC = Mid(c, 255 + 255 + 1, 255)
    End Sub
    Last edited by Yongle; Oct 17th, 2019 at 11:20 AM.

  3. #3
    MrExcel MVP mikerickson's Avatar
    Join Date
    Jan 2007
    Location
    Davis CA
    Posts
    22,645
    Post Thanks / Like
    Mentioned
    20 Post(s)
    Tagged
    15 Thread(s)

    Default Re: Excel VB Textobxes Characters

    What do you want to happen if the delete key is pressed (in TextBoxComments), do you want the characters to come back from TextBoxA to Comments?

  4. #4
    New Member
    Join Date
    Dec 2016
    Posts
    49
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Excel VB Textobxes Characters

    Works like a charm. Thank you so much!!!!!



    Quote Originally Posted by Yongle View Post
    Enter all text in TextBoxComments and then run the code

    Code below written for active-x textboxes embedded in a worksheet
    Code simplified to make it easy to follow
    Place code in SHEET module (not Module1, Module2 etc)

    Code:
    Sub Trans()
        Dim c As String
        c = TextBoxComments.Text
        
        TextBoxComments = Left(c, 255)
        TextBoxA = Mid(c, 255 + 1, 255)
        TextBoxB = Mid(c, 255 + 255 + 1, 255)
        TextBoxC = Mid(c, 255 + 255 + 255 + 1, 255)
    End Sub

    EDIT
    Did I misread your request? Is it this you want?

    Code:
    Sub Trans()
        Dim c As String
        c = TextBoxComments.Text
        
        TextBoxComments = ""
        TextBoxA = Left(c, 255)
        TextBoxB = Mid(c, 255 + 1, 255)
        TextBoxC = Mid(c, 255 + 255 + 1, 255)
    End Sub

  5. #5
    Board Regular
    Join Date
    Mar 2015
    Posts
    4,055
    Post Thanks / Like
    Mentioned
    73 Post(s)
    Tagged
    8 Thread(s)

    Default Re: Excel VB Textobxes Characters

    glad it helped
    thanks for the feedback

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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