#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 31
Default Day Checking

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

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Day Checking

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.


K1KKKA wrote:

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


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,058
Default Day Checking

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


"K1KKKA" wrote:

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


  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 31
Default Day Checking

On 30 Jan, 20:02, Dave Peterson wrote:
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.





K1KKKA wrote:

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


--

Dave Peterson- Hide quoted text -

- Show quoted text -


Thanks Dave,

Worked a treat!!!!

Steve

  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 31
Default Day Checking

On 30 Jan, 20:02, Gary''s Student
wrote:
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



"K1KKKA" wrote:
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- Hide quoted text -


- 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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
checking hyperlinks are valid Garbagh Excel Discussion (Misc queries) 0 November 30th 06 02:16 PM
file size & error checking runaero Excel Discussion (Misc queries) 3 September 26th 06 07:40 PM
Checking balance template in MS excel kindalost Excel Discussion (Misc queries) 1 September 25th 06 02:12 AM
Checking for duplicates - think this is simple [email protected] Excel Discussion (Misc queries) 9 February 27th 06 09:32 PM
Checking names on correct line across sheets Ali Excel Worksheet Functions 5 January 17th 06 07:24 AM


All times are GMT +1. The time now is 11:50 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"