ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Help with UserForm code. (https://www.excelbanter.com/excel-programming/354240-help-userform-code.html)

Richard

Help with UserForm code.
 
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!!

Tom Ogilvy

Help with UserForm code.
 
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
--
Regards,
Topm Ogilvy


"Richard" wrote in message
...
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!!





All times are GMT +1. The time now is 03:03 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com