PDA

View Full Version : [SOLVED] How to export variable from textbox into a cell after clicking on a button?



quetzal
05-16-2016, 07:06 AM
Hi,
I've been solving this for 2 days, trying many different code modification without any success.
I have a user form with button:


Private Sub RunButtonUrgent_Click()
Dim VysleOdpoved As Date
Dim uuu As Date

If UrgentForm.OptionButton1.Value = True Then
VysleOdpoved = uuu
Sheets("SCHEDULE").Range("E5").Value = VysleOdpoved

End If

Unload UrgentForm
End Sub

...and a TextBox1 in the same userform:


Private Sub TextBox1_BeforeUpdate(ByVal Cancel As MSForms.ReturnBoolean)

Dim yourStringDate As Date
Dim uu As String

uu = UrgentForm.TextBox1.Value
yourStringDate = CDate(uu)
uuu = Format(yourStringDate, "dd/mm/yy hh:mm")

End Sub

I would like the date uuu to appear in the cell E5 after clicking on the RunButtonUrgent. This code doesn't want to work. It seams that I don't understand some rules. What do I do wrong????
Thank you!

SamT
05-16-2016, 07:58 AM
Declare uuu before any subs

Dim uuu As Date

Private Sub RunButtonUrgent_Click()
Dim VysleOdpoved As Date

If UrgentForm.OptionButton1.Value = True Then
VysleOdpoved = uuu
Sheets("SCHE

quetzal
05-16-2016, 08:07 AM
Declare uuu before any subs

Dim uuu As Date

Private Sub RunButtonUrgent_Click()
Dim VysleOdpoved As Date

If UrgentForm.OptionButton1.Value = True Then
VysleOdpoved = uuu
Sheets("SCHE

Thank you so much - It worked!