InputBox value

MUKESHY12390

Well-known Member
Joined
Sep 18, 2012
Messages
901
Office Version
  1. 2013
  2. 2011
  3. 2010
  4. 2007
Platform
  1. Windows
Hello.....Frnds
M trying to put ms value in Range("A1") but when i run the Macro2 instead of date it showing Default time 12:00:00 AM, I dont' knw why .?
Pls help me ....Thanks IN Advance!

Code:
Sub macro1()
Dim ms As Date
MsgBox ms
Range("A1").Value = ms
End Sub


Sub macro2()
Dim ms As Date
ms = InputBox("Enter Your Date ")
MsgBox ms
Call macro1
End Sub
'' M trying to put ms value in Range("A1") but instead of date it showing Default time 12:00:00 AM End Sub

[/code]
 
Last edited:

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
Try like this

Code:
Sub test()
With Range("A1")
    .NumberFormat = "dd/mm/yyyy"
    .Value = DateValue(InputBox("Enter date"))
End With
End Sub
 
Upvote 0
not working.... it showing 1/0/1900 in Range("A1")
Currently I hv no choice, I hv to go through the following... way

Code:
Sub macro1()
Dim ms As Date
With Range("A1")
    .NumberFormat = "dd/mm/yyyy"
    .Value = DateValue(ms)
    End With


End Sub


Sub macro2()
Dim ms As Date
ms = InputBox("Enter Your Date ")
MsgBox ms
Call macro1
End Sub
 
Upvote 0
This works

Code:
Sub macro1(ms As String)
With Range("A1")
    .NumberFormat = "dd/mm/yyyy"
    .Value = DateValue(ms)
End With
End Sub


Sub macro2()
Dim ms As String
ms = InputBox("Enter Your Date ")
Call macro1(ms)
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,249
Messages
6,171,031
Members
452,374
Latest member
keccles

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