Results 1 to 3 of 3

Date InputBox in vba

This is a discussion on Date InputBox in vba within the Excel Questions forums, part of the Question Forums category; Hi All, Is there any inputbox type in vba for get the Date type data input? For Example - Below ...

  1. #1
    Board Regular somnath_it2006's Avatar
    Join Date
    Apr 2009
    Location
    Pune, India
    Posts
    574

    Default Date InputBox in vba

    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", Type:=8)
    Appreciate all your help....
    Regards,
    Som



    The more we come out and do good to others, the more our hearts will be purified, and God will be in them. - Swami Vivekananda

  2. #2
    VoG
    VoG is offline
    MrExcel MVP
    Moderator
    VoG's Avatar
    Join Date
    Jun 2002
    Location
    127.0.0.1
    Posts
    62,331

    Default Re: Date InputBox in vba

    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
    HTH, Peter
    Please test any code on a copy of your workbook.

  3. #3
    Board Regular somnath_it2006's Avatar
    Join Date
    Apr 2009
    Location
    Pune, India
    Posts
    574

    Default Re: Date InputBox in vba

    Thank You....
    Regards,
    Som



    The more we come out and do good to others, the more our hearts will be purified, and God will be in them. - Swami Vivekananda

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


DMCA.com