Error Checking in Excel
Thanks Thanks:  0
Likes Likes:  0
Results 1 to 4 of 4

Thread: CREATE INPUTBOX

  1. #1
    Board Regular
    Join Date
    Mar 2002
    Posts
    1,451
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    I want to create an inputbox for a date like 08.05.2002
    After used the OK button then this date must automatickly insert in Cell C4
    Who can help me to create such an inputbox?
    Many thanks

  2. #2
    MrExcel MVP
    Join Date
    Feb 2002
    Location
    Sydney, Australia
    Posts
    2,940
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Default

    Hello,

    How about this?

    Code:
    Sub GetDate()
    Dim vDate As Variant
    Do
        vDate = InputBox("Please enter a date dd/mm/yy", "Get date")
    Loop Until IsDate(vDate) Or vDate = ""
    
    If vDate = "" Then Exit Sub
    
    ActiveSheet.Range("C4").Value = CDate(vDate)
    End Sub
    HTH,
    Dan

  3. #3
    Board Regular
    Join Date
    Mar 2002
    Posts
    1,451
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    On 2002-05-08 04:44, dk wrote:
    Hello,

    How about this?

    Code:
    Sub GetDate()
    Dim vDate As Variant
    Do
        vDate = InputBox("Please enter a date dd/mm/yy", "Get date")
    Loop Until IsDate(vDate) Or vDate = ""
    
    If vDate = "" Then Exit Sub
    
    ActiveSheet.Range("C4").Value = CDate(vDate)
    End Sub
    Thanks Dan,it works fine.But how can I display this inputbox by opening of the workbook.
    Thanks
    HTH,
    Dan

  4. #4
    MrExcel MVP
    Join Date
    Feb 2002
    Location
    Sydney, Australia
    Posts
    2,940
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Default

    OK,

    right click the lower of the two Excel icons at the top left of the screen and choose View Code. Then paste this:-

    Private Sub Workbook_Open()
    Dim vDate As Variant
    Do
    vDate = InputBox("Please enter a date dd/mm/yy", "Get date")
    Loop Until IsDate(vDate) Or vDate = ""

    If vDate = "" Then Exit Sub

    ActiveSheet.Range("C4").Value = CDate(vDate)
    End Sub

    HTH,
    Dan

Some videos you may like

User Tag List

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
  •