Date prompt fr new player to add to sheet 1 column E

chris pike
chris pike used Ask the Experts™
on
I have a sheet, and need to add a prompt to input start date for tne player.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Kesavan JeganarayananIT Consultant

Commented:
Can try this simple VBA script

Sub Testing()
Dim x As Date
x = InputBox("Enter date")
If IsDate(x) Then Range("A1").Value = CDate(x)
End Sub
Group Finance Manager
Commented:
This code will prompt for a date and check the correct format is used. It will force the user to continue until the correct entry is made.

Option Explicit

Sub GetDate()
    Dim oWs As Worksheet
    Dim vDte As Variant
    Set oWs = Sheets("your_sheet_name _here")
TryAgain:
    With oWs
        ''/// enter your required date formaT
        vDte = InputBox("Please Enter the Date *Must be format mm/dd/yyyy*", "Enter Date")
        If vDte = "" Then
            MsgBox ("You did not enter a date!"), vbCritical, "INPUT ERROR"
            GoTo TryAgain    ''/// this will force a retry
            ''/// check that a date has been entered
            If Not IsDate(vDte) Then
                MsgBox ("You did not enter the correct format!"), vbCritical, "INPUT ERROR"
                GoTo TryAgain
            End If
        Else    ''enters date to A1
            oWs.Range("A1").Value = CDate(vDte)
        End If
    End With
End Sub

Open in new window

chris pikeOffice Admin

Author

Commented:
Thanks guys/ Still working on some issues with the sheet. Get back to you soon.
chris pikeOffice Admin

Author

Commented:
Thanks Roy
Roy CoxGroup Finance Manager

Commented:
Pleased to help.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial