Maybe if you use data/validation you could get the right combination of values and format to allow or deny to users to input data.
Hi Andres
You asked this a few days ago and I supplied the following:
I'm assuming your talking about a UserForm with textboxes, if so try the code below. It requires a Userform, TextBox1, Textbox2 and CommandButton1
Option Explicit
Dim DateCheck2 As Date
Dim DateCheck1 As Date
Private Sub CommandButton1_Click()
MsgBox DateDiff("d", DateCheck2, DateCheck1)
End Sub
Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
If Not IsDate(TextBox1) Then
MsgBox "Your date is not valid, please correct it.", vbCritical, "OzGrid Business Applications"
Cancel = True
Else
DateCheck1 = TextBox1.Value
TextBox1 = Format(TextBox1, "dd/mm/yyyy")
End If
End Sub
Private Sub TextBox2_Exit(ByVal Cancel As MSForms.ReturnBoolean)
If Not IsDate(TextBox2) Then
MsgBox "Your date is not valid, please correct it.", vbCritical, "OzGrid Business Applications"
Cancel = True
Else
DateCheck2 = TextBox2.Value
TextBox2 = Format(TextBox2, "dd/mm/yyyy")
End If
End Sub
Dave
OzGrid Business Applications
I tried the code you gave me, but it doesnt work. The part where it says " Private Sub TextBox1_( This right here part the computer wont accept it).
So I dont know. See if it works for you.
Andres
Hey Andres,
The dates used in the calculations; can you set it
up so that the dates are driven by a range in
the worksheet...if you are using a form or data validation
the dates for the calcs will have to be selected
from the range.(this the user has to selet fromt the
list in the format specified)..assuming that the dates can be put
into a range. even if the range is huge, this may work
with a spin button as it will allow for selection
of vast ranges...hope it helps