Results 1 to 5 of 5
  1. #1
    New Lounger
    Join Date
    Mar 2002
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Excel-UserForm-VB (Excel 98)

    I have a userform that has a text box in it I would like the data that I add to the text box to be imported to Sheet1 cell a1after hiding or closing the userform. Also the next time I add info to the text box I would like It to update Cell a2 this time and so on. The program I require is a little bit like MS access but I do not have a copy of Access so I am using Excel as a database
    Can anyone help would I would really appreciate at.

    Thanks
    Jonathon

  2. #2
    Uranium Lounger
    Join Date
    Jan 2001
    Location
    South Carolina, USA
    Posts
    7,295
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Excel-UserForm-VB (Excel 98)

    How is the form closed? Is there a OK button? Do you always want to move down one row in the worksheet every time, even if that cell already contains something, or do you want to store the data after the last used cell in column A?
    Legare Coleman

  3. #3
    New Lounger
    Join Date
    Mar 2002
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Excel-UserForm-VB (Excel 98)

    I would like the information to be stored in a new cell each time and retain the older info in the previous cells.
    I would like to put an "ok" and "Cancel" button in but an not sure about the code required.
    Some advice would be great
    thanks
    Jonathon

  4. #4
    Uranium Lounger
    Join Date
    Jan 2001
    Location
    South Carolina, USA
    Posts
    7,295
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Excel-UserForm-VB (Excel 98)

    Some code like the following in the OK button click event should do the job:

    <pre>Private Sub btnOK_Click()
    Dim lLastRow As Long
    lLastRow = Worksheets("Sheet1").Range("A65536").End(xlUp).Row
    If lLastRow = 1 And Worksheets("Sheet1").Range("A1").Value = "" Then lLastRow = 0
    Worksheets("Sheet1").Range("A1").Offset(lLastRow, 0).Value = frmMyForm.tbMyTextBox.Value
    frmMyForm.Hide
    End Sub
    </pre>

    Legare Coleman

  5. #5
    New Lounger
    Join Date
    Mar 2002
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Excel-UserForm-VB (Excel 98)

    Legare Coleman
    Thanks that is working great I appreciate your help

    Jonathon

Posting Permissions

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