daniels,
Sub GetSunday()
Dim mydate As Date
Dim msg As String
msg = "Enter a Sunday"
GetDate:
mydate = CDate(Application.InputBox(msg, , , , , , , 2))
If Format(mydate, "dddd") < "Sunday" Then
msg = "That wasn't a Sunday, enter a SUNDAY!"
GoTo GetDate
End If
With Range("C5")
.NumberFormat = "mm/dd/yy"
.Value = mydate
End With
End Sub
HTH,
Bernie
MS Excel MVP
"daniels012 " wrote in message
...
I am very new to code. I have created macros in the past.
How can I write code that would let me manipulate data. For example:
I want them to enter a date that automatically puts Sunday in the cell
above it (Cell C5). I have this done in a formula so far!!
What I want if it's not Sunday, is a message box that pops up and says
"the date you entered is not equal to Sunday, change the date. " Then
go back to the cell so they can enter the new date?
I am sure this is basic for some. I just can't get it to work.
---
Message posted from http://www.ExcelForum.com/