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

I would like to apply the "Select Case" to a whole column instead of a single
cell. Could anyone please show me the way. For more information, I apply
the function to a single cell by the followings:-

Sub Test()
Case Is 80
Range("b1").Value = "Good"
Case Is 60
Range("b1").Value = "Fair"
Case Else
Range("b1") = "Unclassified"
End Select
End Sub

Thank you
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Select Case

Post the code you actually use, because what you have there will not
compile; there's no "Select Case ..." statement, so we have no idea what you
are trying to test.
However, I suspect a worksheet formula or conditional formatting would
achieve your goal.

NickHK

"AlanW" wrote in message
...
I would like to apply the "Select Case" to a whole column instead of a

single
cell. Could anyone please show me the way. For more information, I apply
the function to a single cell by the followings:-

Sub Test()
Case Is 80
Range("b1").Value = "Good"
Case Is 60
Range("b1").Value = "Fair"
Case Else
Range("b1") = "Unclassified"
End Select
End Sub

Thank you



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

NickHK, you are right. It should be as follows:-

Sub Test()
Select Case Range("A1")
Case Is 80
Range("b1").Value = "Good"
Case Is 60
Range("b1").Value = "Fair"
Case Else
Range("b1") = "Unclassified"
End Select
End Sub

Do you think it is possible to modify it in order to apply it to a whole
column instead of a cell only?
"NickHK" 來函:

Post the code you actually use, because what you have there will not
compile; there's no "Select Case ..." statement, so we have no idea what you
are trying to test.
However, I suspect a worksheet formula or conditional formatting would
achieve your goal.

NickHK

"AlanW" wrote in message
...
I would like to apply the "Select Case" to a whole column instead of a

single
cell. Could anyone please show me the way. For more information, I apply
the function to a single cell by the followings:-

Sub Test()
Case Is 80
Range("b1").Value = "Good"
Case Is 60
Range("b1").Value = "Fair"
Case Else
Range("b1") = "Unclassified"
End Select
End Sub

Thank you




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Select Case

Not sure where the column comes in ?

You mean test each cell in a column ?
For Each Cell In Range("A1:A10")
Select Case Cell.Value
Case Is 80
Cell.Offset(0, 1).Value = "Good"
Case Is 60
Cell.Offset(0, 1).Value = "Fair"
Case Else
Cell.Offset(0, 1).Value = "Unclassified"
End Select
Next

Unless you feel you may expand the number of comparisons in the future, you
can achieve the result with a formula, then fill down:
=IF(A180,"Good",IF(A160,"Fair","Unclassified"))

NickHK

"AlanW" wrote in message
...
NickHK, you are right. It should be as follows:-

Sub Test()
Select Case Range("A1")
Case Is 80
Range("b1").Value = "Good"
Case Is 60
Range("b1").Value = "Fair"
Case Else
Range("b1") = "Unclassified"
End Select
End Sub

Do you think it is possible to modify it in order to apply it to a whole
column instead of a cell only?
"NickHK" ??:

Post the code you actually use, because what you have there will not
compile; there's no "Select Case ..." statement, so we have no idea what

you
are trying to test.
However, I suspect a worksheet formula or conditional formatting would
achieve your goal.

NickHK

"AlanW" wrote in message
...
I would like to apply the "Select Case" to a whole column instead of a

single
cell. Could anyone please show me the way. For more information, I

apply
the function to a single cell by the followings:-

Sub Test()
Case Is 80
Range("b1").Value = "Good"
Case Is 60
Range("b1").Value = "Fair"
Case Else
Range("b1") = "Unclassified"
End Select
End Sub

Thank you






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

NickHK

THANK YOU VERY MUCH FOR YOUR HELP.


"NickHK" 來函:

Not sure where the column comes in ?

You mean test each cell in a column ?
For Each Cell In Range("A1:A10")
Select Case Cell.Value
Case Is 80
Cell.Offset(0, 1).Value = "Good"
Case Is 60
Cell.Offset(0, 1).Value = "Fair"
Case Else
Cell.Offset(0, 1).Value = "Unclassified"
End Select
Next

Unless you feel you may expand the number of comparisons in the future, you
can achieve the result with a formula, then fill down:
=IF(A180,"Good",IF(A160,"Fair","Unclassified"))

NickHK

"AlanW" wrote in message
...
NickHK, you are right. It should be as follows:-

Sub Test()
Select Case Range("A1")
Case Is 80
Range("b1").Value = "Good"
Case Is 60
Range("b1").Value = "Fair"
Case Else
Range("b1") = "Unclassified"
End Select
End Sub

Do you think it is possible to modify it in order to apply it to a whole
column instead of a cell only?
"NickHK" ??:

Post the code you actually use, because what you have there will not
compile; there's no "Select Case ..." statement, so we have no idea what

you
are trying to test.
However, I suspect a worksheet formula or conditional formatting would
achieve your goal.

NickHK

"AlanW" wrote in message
...
I would like to apply the "Select Case" to a whole column instead of a
single
cell. Could anyone please show me the way. For more information, I

apply
the function to a single cell by the followings:-

Sub Test()
Case Is 80
Range("b1").Value = "Good"
Case Is 60
Range("b1").Value = "Fair"
Case Else
Range("b1") = "Unclassified"
End Select
End Sub

Thank you






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
End Select without Select Case, Block If without End If errors Atreides Excel Programming 12 November 17th 06 05:10 PM
Case Select Jimbola Excel Programming 11 December 11th 05 06:45 PM
Select Case Marcotte A[_3_] Excel Programming 5 June 10th 04 04:05 PM


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