VBA Question!

Samanathon

New Member
Joined
Apr 22, 2002
Messages
12
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
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
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!
 
Upvote 0
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.
 
Upvote 0
^^ 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!
 
Upvote 0
What is the current code that you are using
with the cmd button.
What is the sheet name you are tarnsfering
to.
 
Upvote 0
The sheet name is the defult "Sheet 1", and here is the current code:


20024252523072725963640.jpg




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
 
Upvote 0
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,<font size=+2><font color="red"> Nate<font color="blue">O</font></font></font>
This message was edited by NateO on 2002-04-26 15:26
 
Upvote 0

Forum statistics

Threads
1,214,644
Messages
6,120,709
Members
448,983
Latest member
Joaquim_Baptista

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top