Date InputBox in vba

somnath_it2006

Well-known Member
Joined
Apr 11, 2009
Messages
574
Hi All,

Is there any inputbox type in vba for get the Date type data input?

For Example -

Below input box is for select the range:
Code:
Set MyRange = Application.InputBox(Prompt:="Select any range", Title:="Demo", [COLOR="Red"]Type:=8[/COLOR])

Appreciate all your help....
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
There isn't a type for dates. You can read the date as a string and convert it like this

Code:
Sub GetADate()
Dim TheString As String, TheDate As Date
TheString = Application.InputBox("Enter A Date")
If IsDate(TheString) Then
    TheDate = DateValue(TheString)
Else
    MsgBox "Invalid date"
End If
End Sub
 
Upvote 0
There isn't a type for dates. You can read the date as a string and convert it like this

Just in case anybody else comes across this, there is a code that is practically a date.

Code:
StartDate = Application.InputBox(MsgGP, TitleMsg, FormatDateTime(Date, vbShortDate), Type:=1)
 
Upvote 0

Forum statistics

Threads
1,223,630
Messages
6,173,457
Members
452,516
Latest member
archcalx

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