LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default select case statement


I have a select case statement that recognizes numbers and can tell me
when they are out of range, but when text or anything other than
numbers are entered, the macro has a problem. It says type mismatch and
highlights the below underlined statement. My question is how can I
have it accept text, to allow a error message to pop up.

Sub color()
Dim c As Range
Dim msg, error As String
msg = "Please enter a value between 1 and 5."
error = "ERROR!"

For Each c In Selection
c.NumberFormat = "0"

_Select_Case_Application.WorksheetFunction.Round(c .Value,_3)_

Case Is = 1
c.Interior.color = vbGreen
c.Font.color = vbWhite
Case Is = 2
c.Interior.color = vbBlue
c.Font.color = vbWhite
Case Is = 3
c.Interior.color = vbYellow
c.Font.color = vbBlack
Case Is = 4
c.Interior.color = RGB(255, 153, 0)
c.Font.color = vbBlack
Case Is = 5
c.Interior.color = vbRed
c.Font.color = vbWhite
Case Else
c.Interior.color = vbBlack
c.Font.color = vbWhite
Response = MsgBox(msg, vbOKOnly, error)

End Select
Next c
End Sub

-joe


--
jrd269
------------------------------------------------------------------------
jrd269's Profile: http://www.excelforum.com/member.php...o&userid=23815
View this thread: http://www.excelforum.com/showthread...hreadid=376273

 
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
Select Case Statement Katie Excel Worksheet Functions 13 December 1st 08 07:32 PM
Case without Select Case error problem Ayo Excel Discussion (Misc queries) 2 May 16th 08 03:48 PM
Select Case Statement does not evaluate Jeff[_44_] Excel Programming 11 April 6th 05 09:32 PM
Convert If..Else to Select Case Statement. Sheela Excel Programming 1 July 25th 03 09:28 AM
Data validation with the Select Case statement acw Excel Programming 0 July 15th 03 03:16 AM


All times are GMT +1. The time now is 08:25 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"