Error Checking in Excel
Thanks Thanks:  0
Likes Likes:  0
Results 1 to 10 of 10

Thread: VBA Question!

  1. #1
    New Member Samanathon's Avatar
    Join Date
    Apr 2002
    Posts
    12
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Okey, here is the deal:

    I have made a Userform that includes 3 text boxes that a user would input info into (the userform has "OK" & "Cancel" buttons as well).

    When the "OK" button is clicked, the code will insert a new row (lets say row A) and input the info from the text boxes in the cells (A1, A2, A3).

    What command would I use to take the info (that that the user inputted into the text boxes) and place them into the new A1, A2 & A3 cells?

    ------------------------

    I have programed the Userform to insert that new row as soon as the button that activates the userform is press, but I don't think that I would like keep it like this - because the cancel button doesn't undo the insert . . .

    -Thanks!!!
    Samanathon

  2. #2
    Board Regular
    Join Date
    Mar 2002
    Location
    Cincinnati, Ohio, USA
    Posts
    6,824
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Something like this...

    Sheet1.Range("A1") = TextBox1.Text

    Tom

  3. #3
    New Member Samanathon's Avatar
    Join Date
    Apr 2002
    Posts
    12
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Thanks for the reply Tom!

    I am still having a bit of trouble with this text box . . .

    I tried "Sheet1.Range("A1") = TextBox1.Text" but still couldn't get it to work

    -------------------------------

    Some more info:

    1. User clicks a button that activates a user form

    2. Userform has three text boxes

    3. After entering info, user clicks "OK"

    4. Info is inputted into cells

    5. Userform hides

    ----------------------------------

    ^^ I am having trouble with #4 of this example.

    Thanks for all of your help!

  4. #4
    Board Regular
    Join Date
    Feb 2002
    Location
    Where the wild roses grow
    Posts
    285
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Try this:

    worksheets("sheet1").range("a1").value=textbox1

    Audiojoe

  5. #5
    New Member
    Join Date
    Apr 2002
    Location
    Lawrence, KS
    Posts
    29
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    On 2002-04-23 21:30, Samanathon wrote:

    When the "OK" button is clicked, the code will insert a new row (lets say row A) and input the info from the text boxes in the cells (A1, A2, A3).

    I have programed the Userform to insert that new row as soon as the button that activates the userform is press, but I don't think that I would like keep it like this - because the cancel button doesn't undo the insert . . .
    Ok, I am a little confused here, when exactly are you inserting the new row? Because you should insert it after the OK button on the User Form is clicked. You should not insert the new row as soon as the User Form is activated. That way the cancel button doesn't have to undo anything because nothing is done until OK is clicked.

  6. #6
    New Member Samanathon's Avatar
    Join Date
    Apr 2002
    Posts
    12
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    ^^ I know, that's just how I have it right now - I've never really played around with Userforms until now. I will change it though.

    -Thanks!

  7. #7
    MrExcel MVP Ivan F Moala's Avatar
    Join Date
    Feb 2002
    Location
    Auckland, New Zealand
    Posts
    4,209
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    What is the current code that you are using
    with the cmd button.
    What is the sheet name you are tarnsfering
    to.


    Kind Regards,
    Ivan F Moala From the City of Sails

  8. #8
    New Member Samanathon's Avatar
    Join Date
    Apr 2002
    Posts
    12
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    The sheet name is the defult "Sheet 1", and here is the current code:






    Private Sub Cancel_Click()
    Message = "Do you really want to back out " _
    & "be a wimp?"
    'This will ask the user to confirm that they
    ' wish to close the Userform.
    If MsgBox(Message, vbYesNo) = vbYes Then
    Hide
    'If they click "Yes", then it will close!
    End If
    'If they click "No", the comfirmation box closes.
    End Sub
    -------------------------------------------
    Private Sub Input_Date_Change()

    End Sub
    -------------------------------------------
    Private Sub Input_DRO_Number_Change()

    End Sub
    -------------------------------------------
    Private Sub Input_Show_Name_Change()

    End Sub
    -------------------------------------------
    Private Sub Input_Show_Click()
    ' Insert_A_Row_A6 Macro
    ' Macro recorded 4/23/2002 by Saman Sadeghi
    ' Rows("6:6").Select
    Selection.Insert Shift:=xlDown
    'This will insert a new row at cell A6
    End Sub

  9. #9
    New Member Samanathon's Avatar
    Join Date
    Apr 2002
    Posts
    12
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Anyone?

  10. #10
    Legend NateO's Avatar
    Join Date
    Feb 2002
    Location
    Minneapolis, Mn, USA
    Posts
    9,700
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Lemme see, try to break it down to the nitty gritty. Go into the Visual basic editor. Go into your userform module (not a normal module, in the project expolorer, this module is located in the "forms" folder, expand the contents of this folder), it's probably "userform1", you can browse modules with the project explorer. Figure out the name of your "OK" button and the name of your "Textbox", you can find out/verify by right-clicking on these items in the vbe and select properties. Right click on your form and place the following:

    Code:
    Private Sub CommandButton1_Click()
    Sheet1.[a1] = TextBox1.Text
    End Sub
    Change CommandButton1 to the name of your "Ok" button and change TextBox1 to the name of your textbox. Hope this helps.

    _________________
    Cheers, NateO

    [ This Message was edited by: NateO on 2002-04-26 15:26 ]

Some videos you may like

User Tag List

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
  •