Help with UserForm code.

G

Guest

I have TextBox1, CommandButton1 and CommandButton2. When user inputs a number
in TextBox1 and then clicks CommandButton1, I need that number sent to
"Sheet4" Cell "B2" and a msgbox stating that "Whatever number was entered had
been added to your Vacation". If CommandButton2 is selected UserForm closes.
I understand I'm asking a lot! Thanks in advance for any help!!
 
T

Tom Ogilvy

Private Sub CommandButton1_Click()
Worksheets("Sheet4").Range("B2").Value = cdbl(Textbox1.Text)
msgbox Textbox1.Text & " was added to your vacation"
End sub

Private Sub CommandButton2_Click()
Unload Me
End Sub


if you want to add the number in the textbox to any value alreadyi n B2 it
would be
Private Sub CommandButton1_Click()
With Worksheets("Sheet4")
.Range("B2").Value = .Range("B2").Value + cdbl(Textbox1.Text)
End With
msgbox Textbox1.Text & " was added to your vacation"
End sub


If the number will be an integer, you can replace cdbl with clng
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top