Need VBA input box for date and if not msgbox requiring date

Caveman1964

Board Regular
Joined
Dec 14, 2017
Messages
121
I tried this but doesn't work.
it will say, not a data even when putting in a date and doesn't clear what they put in text box form. It is a user form.
If they put nothing, i have a user form comes up for that but can't figure out this date thing. They have to enter a date.
Any help would be much appreciated

Private Sub entcomprecdatebutton_Click()
Sheets("Do Not Alter").Unprotect "1"
Sheets("Data Collection").Unprotect "1"
Sheets("Complaint Entry").Unprotect "1"


Sheets("Complaint Entry").Select
Range("E6").Select
If entcompdatetextbox.Value = "" Then
missingcompnum.Show
Exit Sub
End If


If IsDate(mbox) Then
dte = CDate(mbox)
Range("E6") = dte
Else: msgbox "This isn't a date, try again."


End If


ActiveCell = entcompdatetextbox.Value
Unload Me
entdatecrmform.Show


End Sub
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
I am not 100% sure what you are asking but here is the code for my userform date that requires entry before going forward


Code:
Private Sub CommandButton1_Click()

' Created by Rob Rush 2018
Application.ScreenUpdating = False

' Checks that a valid date has been entered

If IsDate(Trim(TextBox1.Text)) = False Then
MsgBox "Please enter the correct date"
Else
' Changes Date format to one use by board
TextBox1.Text = Format(TextBox1.Text, "mm/dd/yyyy")

' Shows all sheets and selects Board Creator. Also puts date in place
Worksheets("BOARD GENERATOR").Visible = True
Worksheets("CONTROL PANEL").Visible = True
Worksheets("Ticket Leads").Visible = True
Worksheets("Admissions Leads").Visible = True
Worksheets("UBO Leads").Visible = True
Worksheets("Booth 1").Visible = True
Worksheets("Booth 2").Visible = True
Worksheets("Booth 3").Visible = True
Worksheets("Booth 4").Visible = True
Worksheets("Will Call").Visible = True
Worksheets("Admissions Hosts").Visible = True
Worksheets("UBO Associates").Visible = True
Worksheets("Ambassadors").Visible = True
Worksheets("EET").Visible = True
Worksheets("Strollers").Visible = True
Worksheets("Dispatchers").Visible = True
Worksheets("Ambassador Leads").Visible = True
Worksheets("Tickets").Visible = True
Worksheets("UBO").Visible = True
Worksheets("Plaza").Visible = True
Worksheets("Dispatch").Visible = True
Worksheets("Rentals").Visible = True


Sheets("BOARD GENERATOR").Select
Range("D8").Select
Range("D8").Value = TextBox1.Value
UserForm3.Hide
Application.ScreenUpdating = True
End If


End Sub
 
Upvote 0
it did bring the message box up if there was not date and was just text....but when i clicked ok on the message, it still put the values in the cell and moved on to next form.
I'll keep trying something.....thank you for spending the time to send to me!
 
Upvote 0
I tried this but doesn't work.
it will say, not a data even when putting in a date and doesn't clear what they put in text box form. It is a user form.
If they put nothing, i have a user form comes up for that but can't figure out this date thing. They have to enter a date.
Any help would be much appreciated

Maybe something like this:

Code:
Private Sub CommandButton1_Click()

If IsDate(TextBox1) Then
    ActiveCell = CDate(TextBox1)
Else
    MsgBox "You must insert date"
    TextBox1.SetFocus
    TextBox1 = ""
End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,926
Messages
6,122,305
Members
449,079
Latest member
juggernaut24

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top