Gettin a Date from a User

kpierce

Board Regular
Joined
Jun 21, 2010
Messages
76
Hello -
I have been working trying to get a marco to accept a date from users.

However everytime I run this, sDefault returns today's date.

I do believe there is a calendar built in, is that a better way of getting dates? If so, is there a way I could lock the date down to a Friday? If so, how do I call this calendar, lock it to only friday (if possible), and place the date in a variable called sDefault?

thanks in advance.

Dim ws As Worksheet, PMSheet As String, OrgSheet As String
Dim sUserName As String
Dim sPrompt As String
Dim sTitle As String
Dim sDefault As Date
' Get Date
sPrompt = "Enter Date"
sTitle = "Date"
sDefault = Date
sUserName = InputBox(sPrompt, sTitle, sDefault)

'Always returns today.
MsgBox sDefault
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
Maybe

Code:
Dim ws As Worksheet, PMSheet As String, OrgSheet As String
Dim sUserName As String
Dim sPrompt As String
Dim sTitle As String
Dim sDefault As Date
Dim s As String
' Get Date
sPrompt = "Enter Date"
sTitle = "Date"
sDefault = Date
x = InputBox(sPrompt, sTitle, sDefault)
sDefault = DateValue(x)
'Always returns today.
MsgBox sDefault

Look here http://fontstuff.com/vba/vbatut07.htm
 
Upvote 0
Thank you...
I have been looking around and it seems it might be easier to get a Date via a calendar control.

Everything I see seems to be very complicated.

I just want to get a date and make sure it is a Friday, otherwise I want to kick out an error.

The calendar controls looks pretty slick, but that may be more complicated than I need.

Is there an EASY way to do this?

thanks in advance.
 
Upvote 0
I have been working trying to get a marco to accept a date from users.

Marco doesn't do dates, he prefers to be alone...

I just want to get a date and make sure it is a Friday

buy her some flowers and just ask her!!
btw, Friday is a perfect day to go on a date.

hope that helps,
H
 
Upvote 0

Forum statistics

Threads
1,224,583
Messages
6,179,682
Members
452,937
Latest member
Bhg1984

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