Hi all
Hope You Can you help me?
Inside the userform I need to create textbox=TB that have validation so the TB.value is a date formated "dd.MM.yyyy HH:mm" example("17.02.2014 17:05")
the TB.value will be add to the specific cells example (A1) then it is a date with same format! And if the another cell = A1 Format general, then that cell value shod be (Example 46215,13151)
If the user will make mistake with format or with nr values, then he cant exit from TB ( Cancel=True! ) or it will corrected automatically!
Code i used, but it will not give a positive result!
If the user make mistake even by putting two space between time and date then it will not find error!
Private Sub Alg_enter()
Alg.Value = Now
Alg.Text = VBA.Format(Now, "dd.MM.yyyy HH:mm")
End Sub
Private Sub Alg_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Dim Alg As Date
Dim aeg As Double
'aeg = Me.Alg.Value
'Me.Alg.Value = aeg
Me.Alg.Value = VBA.Format(Me.Alg.Value(), "dd.MM.yyyy HH:mm")
End Sub
Sub Check_Lop_Exit(ByVal Cancel As MSForms.ReturnBoolean)
If Check_Lop.Value = True Then
Lop.Enabled = True
Else
Lop.Enabled = False
End If
End Sub
Private Sub Lop_Enter()
'Lop.Value = Now
'Lop.Value = Format(Now(), "dd.mm.yyyy hh:mm")
Lop.Value = Now
Lop.Text = VBA.Format(Now, "dd.MM.yyyy HH:mm")
End Sub
Sub Lop_Exit(ByVal Cancel As MSForms.ReturnBoolean)
If Check_Lop.Value = True Then
'MsgBox "Aeg puudu!", vbCritical
'Dim küsim, küsim2
'küsim = MsgBox("Kas tahad aega uuesti sisestada?", vbYesNo)
' If küsim = 6 Then
' Cancel = True
' End If
Lop.Text = VBA.Format(Lop.Text(), "dd.MM.yyyy HH:mm")
Dim küsim2 As Byte
If Lop.Value < Alg.Value Then
'
MsgBox "Kontrolli aega! Algus: " & Alg.Value & "Lõpp: " & Lop.Value
küsim2 = MsgBox("Kas Tahad parandada?", vbYesNo, "Edasise tegevuse kinnitus!")
If küsim2 = 6 Then
Cancel = True
Else
End If
End If
ElseIf Check_Lop.Value = False Then
Lop.Value = ""
End If
End Sub
Bookmarks