#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Select Case

Hi Group,
I don't know exactly what I'm doing with this VBA:

Select Case Cells(r, "K").Value
Case Is < "m&/&d&/&yy"
MsgBox "You have entered an invalid date."

That does not work. What I'm "trying " to do is check a cell that
contains a date to see if it has extraneous characters causing an
invalid date. I'm trying to prevent usiers from mis-typing things into
the cell such as *or ' or // or " for instance. I just can't wrap my
head around a proper way to set it up. I have another Select Case that
checks to see if a cell contains a weekend date, and it works very
well until someone mis-types the aforementioned instances:

Select Case Weekday(Cells(r, "K").Value)
Case 1, 7

MsgBox "You have entered a weekend date." _
& vbLf & "Please enter the date for Friday, or the date
for Monday!"

Cells(r, "K").ClearContents
Case 2, 3, 4, 5, 6
Case Else

If anyone can point me in the right direction, the help will be most
greatly appreciated. Thank so much to the group!
Ken
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Select Case

if IsDate(Cells(r, "K").Value ) then

Select Case Weekday(Cells(r, "K").Value)
Case 1, 7

MsgBox "You have entered a weekend date." _
& vbLf & "Please enter the date for Friday, or the date
for Monday!"

Cells(r, "K").ClearContents
Case 2, 3, 4, 5, 6
Case Else
else
MsgBox "You have entered an invalid date."
end if


"Ken" wrote:

Hi Group,
I don't know exactly what I'm doing with this VBA:

Select Case Cells(r, "K").Value
Case Is < "m&/&d&/&yy"
MsgBox "You have entered an invalid date."

That does not work. What I'm "trying " to do is check a cell that
contains a date to see if it has extraneous characters causing an
invalid date. I'm trying to prevent usiers from mis-typing things into
the cell such as *or ' or // or " for instance. I just can't wrap my
head around a proper way to set it up. I have another Select Case that
checks to see if a cell contains a weekend date, and it works very
well until someone mis-types the aforementioned instances:

Select Case Weekday(Cells(r, "K").Value)
Case 1, 7

MsgBox "You have entered a weekend date." _
& vbLf & "Please enter the date for Friday, or the date
for Monday!"

Cells(r, "K").ClearContents
Case 2, 3, 4, 5, 6
Case Else

If anyone can point me in the right direction, the help will be most
greatly appreciated. Thank so much to the group!
Ken

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
Case without Select Case error problem Ayo Excel Discussion (Misc queries) 2 May 16th 08 03:48 PM
Select case or If then Lenny Excel Programming 3 August 28th 07 04:34 PM
End Select without Select Case, Block If without End If errors Atreides Excel Programming 12 November 17th 06 05:10 PM
Select Case Adam Ghahramani Excel Programming 0 March 21st 06 06:08 PM


All times are GMT +1. The time now is 07:26 AM.

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"