Results 1 to 6 of 6

Thread: [RESOLVED] Excel form

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2005
    Location
    Long Island, NY.
    Posts
    353

    Resolved [RESOLVED] Excel form

    I have a small form in excel (textbox1, textbox2, cmdbutton1)

    When a use hits submit I want the data in textbox1 and textbox2 to display on my Worksheet(1) spreadsheet; textbox1 value into Column A and textbox2 in Column B.

    I already have 80 rows in this sheet so how do I make it add a new row everytime.

  2. #2
    Lively Member
    Join Date
    Nov 2005
    Location
    Oxford UK
    Posts
    76

    Re: Excel form

    This is the solution for you using vb code. Open the forms code box in vb mode (I guess you used excel vb to create the form), then apply this code

    Code:
    Private Sub cmdbutton1_Click()
    Dim iRow As Long
    Dim ws As Worksheet
    Set ws = Worksheets("sheet1")
    
      'moves to the next empty row
      iRow = ws.Cells(Rows.Count, 1) _
      .End(xlUp).Offset(1, 0).Row
    
      'enters data onto sheet1
      ws.Cells(iRow, 1).Value = Me.textbox1.Value
      ws.Cells(iRow, 2).Value = Me.textbox2.Value
    
      'resets form
      Me.textbox1.Value = ""
      Me.textbox2.Value = ""
    
    End Sub

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2005
    Location
    Long Island, NY.
    Posts
    353

    Re: Excel form

    Thanks sir! I will try right now.

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2005
    Location
    Long Island, NY.
    Posts
    353

    Re: Excel form

    Worked perfect! THanks!

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2005
    Location
    Long Island, NY.
    Posts
    353

    Re: Excel form

    Is there anyway I can find the syntax how to do this stuff without asking??

  6. #6
    Lively Member
    Join Date
    Nov 2005
    Location
    Oxford UK
    Posts
    76

    Re: [RESOLVED] Excel form

    sorry, I don't no of any website that provides complete reference for coding but if you find one be sure to let me know

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