ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Get Day from Date to Validate (https://www.excelbanter.com/excel-discussion-misc-queries/106061-get-day-date-validate.html)

David

Get Day from Date to Validate
 
I am trying to ensure that the user enters the first day of the month when
prompted, so I need to test the day from the date entered. The month and year
do not matter. Thanks!
Here is what I have, but it does not work:

myDate = InputBox(Prompt:="Enter the FIRST DAY of the Month you want to
Create", _
Default:=Format(Date, "mm/dd/yy"))

DayDate = myDate(Day) '(THIS IS WHERE THE PROBLEM IS)
If DayDate < 1 Then
Msg = " You Did Not Enter The First Day of The Month" & Chr(10) & _
" Are You SURE You Want To Continue?"
Ans = MsgBox(Msg, vbYesNo)
If Ans = vbNo Then Exit Sub
End If

Toppers

Get Day from Date to Validate
 

DayDate = Day(myDate)

HTH

"David" wrote:

I am trying to ensure that the user enters the first day of the month when
prompted, so I need to test the day from the date entered. The month and year
do not matter. Thanks!
Here is what I have, but it does not work:

myDate = InputBox(Prompt:="Enter the FIRST DAY of the Month you want to
Create", _
Default:=Format(Date, "mm/dd/yy"))

DayDate = myDate(Day) '(THIS IS WHERE THE PROBLEM IS)
If DayDate < 1 Then
Msg = " You Did Not Enter The First Day of The Month" & Chr(10) & _
" Are You SURE You Want To Continue?"
Ans = MsgBox(Msg, vbYesNo)
If Ans = vbNo Then Exit Sub
End If


David

Get Day from Date to Validate
 
Thank you VERY much!
That did it.. :)

"Toppers" wrote:


DayDate = Day(myDate)

HTH

"David" wrote:

I am trying to ensure that the user enters the first day of the month when
prompted, so I need to test the day from the date entered. The month and year
do not matter. Thanks!
Here is what I have, but it does not work:

myDate = InputBox(Prompt:="Enter the FIRST DAY of the Month you want to
Create", _
Default:=Format(Date, "mm/dd/yy"))

DayDate = myDate(Day) '(THIS IS WHERE THE PROBLEM IS)
If DayDate < 1 Then
Msg = " You Did Not Enter The First Day of The Month" & Chr(10) & _
" Are You SURE You Want To Continue?"
Ans = MsgBox(Msg, vbYesNo)
If Ans = vbNo Then Exit Sub
End If



All times are GMT +1. The time now is 12:25 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com