Day Checking

K

K1KKKA

Am using the formula below to check whether the current day in cell F2
is a Monday, if so i would like to have the 'FrmMon' allowed to be
shown, but if the cell F2 is any other day of the week it will display
the msgbox and not show the 'FrmMon'

obviously i am pasting it into this site because it is not working as
i expected, anyone know how to change the code to perform the task??

Would appreciate any assistance :)

Sub MonData()
If (Range("F2")) = "Monday" Then Exit Sub
MsgBox "Unable to Continue"
frmMon.Show
End Sub



Steve
 
D

Dave Peterson

One way:

Option Explicit
Sub MonData()
If Weekday(Worksheets("sheet999").Range("F2").Value) = vbMonday Then
frmMon.Show
Else
MsgBox "Unable to Continue"
End If
End Sub

I'd specify that worksheet, too.
 
G

Gary''s Student

In this code I use DATEVALUE to insure we have a "real" date. I use FORMAT
just to get a text string as in your post:


Sub marine()
v = Format((DateValue(Range("F2").Value)), "dddd")
MsgBox (v)
If v = "Monday" Then
Exit Sub
End If
MsgBox "Unable to Continue"
End Sub

you can remove the first MSGBOX, its only for debugging.
 
K

K1KKKA

One way:

Option Explicit
Sub MonData()
If Weekday(Worksheets("sheet999").Range("F2").Value) = vbMonday Then
frmMon.Show
Else
MsgBox "Unable to Continue"
End If
End Sub

I'd specify that worksheet, too.










--

Dave Peterson- Hide quoted text -

- Show quoted text -

Thanks Dave,

Worked a treat!!!!

Steve
 
K

K1KKKA

In this code I use DATEVALUE to insure we have a "real" date. I use FORMAT
just to get a text string as in your post:

Sub marine()
v = Format((DateValue(Range("F2").Value)), "dddd")
MsgBox (v)
If v = "Monday" Then
Exit Sub
End If
MsgBox "Unable to Continue"
End Sub

you can remove the first MSGBOX, its only for debugging.
--
Gary's Student
gsnu200703









- Show quoted text -

This option did work to, gary, thanks,

But have chosen to go with Daves version on this occasion, thank you
both for your assistance


Steve
 
Top