+ Reply to Thread
Results 1 to 10 of 10

Move userform TextBox entries to cells on a sheet

Hybrid View

  1. #1
    Forum Contributor rkjudy's Avatar
    Join Date
    03-31-2009
    Location
    Longview, TX
    MS-Off Ver
    MS Office 2010
    Posts
    239

    Move userform TextBox entries to cells on a sheet

    My question is simple. I have a CommandButton on a worksheet named 'Workup' that, when clicked, presents a userform with 15 textboxes (TextBox1 through TextBox15). I have CommandButton1 on the userform also. When I click CommandButton1, I want the value in the textboxes to be placed in cell A1 thru A15 on the sheet named 'Invoice". I think it's just a repeat of the same line of code for each of the 15 TextBoxes. Once the cells on the sheet 'Invoice' are populated, I want to print the sheet 'Invoice' on the default printer. Then, return to the original sheet named 'Workup' and close the userform. The reason I'm using a userform is because the CommandButton does several other things also. Thanks in advance.
    Last edited by rkjudy; 01-10-2011 at 10:58 AM.

  2. #2
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,327

    Re: Move userform TextBox entries to cells on a sheet

    Without seeing your workbook and knowing where you are storing values, how about this sample. Place the code behind the form.

    Private Sub cmbAdd_Click()
        'next empty cell in column A
        Set c = Range("A65536").End(xlUp).Offset(1)
        Application.ScreenUpdating = False    'speed up, hide task
        'write userform entries to database
        With Me
            c.Value = .TextBox1.Value
            c.Offset(1).Value = .TextBox2.Value
            c.Offset(2).Value = .TextBox3.Value
            c.Offset(3).Value = .TextBox4.Value
            'clear the form
            ClearControls
        End With
        Application.ScreenUpdating = True
    End Sub
    Last edited by jeffreybrown; 01-08-2011 at 11:22 PM.
    HTH
    Regards, Jeff

  3. #3
    Forum Contributor rkjudy's Avatar
    Join Date
    03-31-2009
    Location
    Longview, TX
    MS-Off Ver
    MS Office 2010
    Posts
    239

    Re: Move userform TextBox entries to cells on a sheet

    I'm new to VB and I didn't really understand the explanation so I've included an 'Example' sheet for you to see what I am trying to do. Thanks.

  4. #4
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,327

    Re: Move userform TextBox entries to cells on a sheet

    No problem, I don't see your workbook.

  5. #5
    Forum Contributor rkjudy's Avatar
    Join Date
    03-31-2009
    Location
    Longview, TX
    MS-Off Ver
    MS Office 2010
    Posts
    239

    Re: Move userform TextBox entries to cells on a sheet

    Sorry for the oversight. Here's the workbook.
    Attached Files Attached Files

  6. #6
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,327

    Re: Move userform TextBox entries to cells on a sheet

    Try this...
    Attached Files Attached Files

+ 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.6.0 RC 1