+ Reply to Thread
Results 1 to 11 of 11

Thread: Multiple words in textbox to different columns

  1. #1
    Forum Contributor
    Join Date
    07-16-2009
    Location
    Bucharest, Romania
    MS-Off Ver
    MS Office 2007
    Posts
    157

    Multiple words in textbox to different columns

    Hi,

    I have a textbox in which I'll need to insert a link and a username spearted by a single space.
    For instance:

    excelforum.com Alexander Ceed

    I need everything up to the first space placed in a column and everything else from the first space placed in a different column but all on the same table.

    For example:
    excelforum.com in TEST1
    Alexander Ceed in TEST2

    Please help. Thank you

  2. #2
    Forum Guru, retired Admin royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    25,616

    Re: Multiple words in textbox to different columns

    Where's the TextBox?
    Hope that helps.

    RoyUK
    --------
    If you are pleased with a member's answer then use the Star icon to rate it, if you are pleased enough to part with cash consider a donation to Children in Need

    For Excel Tips & Solutions, free examples and tutorials why not check out my downloads

    New members please read & follow the Forum Rules

    Remember to mark your questions Solved and rate the answer(s)

  3. #3
    Forum Contributor
    Join Date
    07-16-2009
    Location
    Bucharest, Romania
    MS-Off Ver
    MS Office 2007
    Posts
    157

    Re: Multiple words in textbox to different columns

    Quote Originally Posted by royUK View Post
    Where's the TextBox?
    Don't know if this the right answer.. It's in a form

  4. #4
    Valued Forum Contributor alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Lake County, Illinois
    MS-Off Ver
    MS Office 2010, 2007 and 2002
    Posts
    1,155

    Re: Multiple words in textbox to different columns

    Alexander;
    Let me make sure I understand your needs. You have a textbox on a form with an entry that looks like "excelforum.com Alexander Ceed". You wish for the data to be stored in a table in two different fields. In field one you would have excelforum.com and in field two, Alexander Ceed.

    Is this something that you wish to do one time or it will be done on a continuous basis? Is the information in the text box, coming from manual data entry or is it being imported from another source?

    Last question: Excel spreadsheet or Access Form?

    Alan
    Last edited by alansidman; 12-18-2010 at 02:52 PM.

  5. #5
    Forum Guru, retired Admin royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    25,616

    Re: Multiple words in textbox to different columns

    presumably a UserForm. this code is for a button on the userform.
    Option Explicit
    
    Private Sub CommandButton1_Click()
        Dim vText As Variant
        Dim NextRw As Long
    
        vText = Split(Me.TextBox1.Value, " ")
        With Sheet1
            NextRw = .Cells(.Rows.Count, 1).End(xlUp).Row + 1
            .Cells(NextRw, 1).Value = vText(0)
            .Cells(NextRw, 2).Value = vText(1)
        End With
    End Sub
    Hope that helps.

    RoyUK
    --------
    If you are pleased with a member's answer then use the Star icon to rate it, if you are pleased enough to part with cash consider a donation to Children in Need

    For Excel Tips & Solutions, free examples and tutorials why not check out my downloads

    New members please read & follow the Forum Rules

    Remember to mark your questions Solved and rate the answer(s)

  6. #6
    Forum Contributor
    Join Date
    07-16-2009
    Location
    Bucharest, Romania
    MS-Off Ver
    MS Office 2007
    Posts
    157

    Re: Multiple words in textbox to different columns

    royUK,
    I'm no expert here but that's an excel code if I'm not mistaken. The form is in an access database.

    Alan,
    That's exactly what I need. It will be on a continuous basis and the data is entered manually.

    Thanks for looking into it guys. I appreciate your efforts.

  7. #7
    Valued Forum Contributor alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Lake County, Illinois
    MS-Off Ver
    MS Office 2010, 2007 and 2002
    Posts
    1,155

    Re: Multiple words in textbox to different columns

    Alexander,
    If the data is being entered manually, then why don't you create two text boxes that are bound to two fields in your table and enter the appropriate data in each text box? I am confused as to why you would enter all the data into one text box only to split it into two fields.

    Alan

  8. #8
    Forum Guru, retired Admin royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    25,616

    Re: Multiple words in textbox to different columns

    Access has the Split Function as well as Excel.
    Hope that helps.

    RoyUK
    --------
    If you are pleased with a member's answer then use the Star icon to rate it, if you are pleased enough to part with cash consider a donation to Children in Need

    For Excel Tips & Solutions, free examples and tutorials why not check out my downloads

    New members please read & follow the Forum Rules

    Remember to mark your questions Solved and rate the answer(s)

  9. #9
    Forum Contributor
    Join Date
    07-16-2009
    Location
    Bucharest, Romania
    MS-Off Ver
    MS Office 2007
    Posts
    157

    Re: Multiple words in textbox to different columns

    Alan,
    The reason is the clutter. I already have a lot of textboxes and I was thinking to cut-down on some of them by interting multiple data in a single textbox.

  10. #10
    Valued Forum Contributor alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Lake County, Illinois
    MS-Off Ver
    MS Office 2010, 2007 and 2002
    Posts
    1,155

    Re: Multiple words in textbox to different columns

    I would urge you to reconsider and not short cut yourself when it comes to fields and controls. If you have them bound and don't need any manipulation the chances of something going awry is mitigated. It helps to keep it simple for users. With multiple entries in a control, what is to prevent the user from entering to many spaces, or not enough spaces to separate properly. Punctuation that is not necessary, or improper capitalization. I personally would go for the extra text boxes. Perhaps set up your form with tabs or pages so it doesn't look so cluttered. If you consider tabs, here is a video that will help.

    http://www.datapigtechnologies.com/f...abcontrol.html

    Alan

  11. #11
    Registered User
    Join Date
    01-02-2011
    Location
    Manchester
    MS-Off Ver
    Excel 2010
    Posts
    29

    Re: Multiple words in textbox to different columns

    I have to agree you should use separate text boxes at all times for such types of data capture - an alternative to tabs would be to create a pop-form this would overlay your current open form and provides space for additional data capture.

+ 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.2.0