View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Beertje Beertje is offline
external usenet poster
 
Posts: 10
Default Passing a string to Case statement

For 1 entry no problem but how to get this work for 2 or more like:
"ABC", "DEF", "GHI"

thx.

"papou" wrote:

Hello Beertje
Declare your variable as String and may be constant as well:
Const CaseVariable As String = "ABC"
Select Case Cells(i,8)
Case CaseVariable
'....

HTH
Cordially
Pascal

"Beertje" a écrit dans le message de
news: ...
My current code reads:


Select Case Cells(i, 8)
Case "ABC", "DEF", "GHI"
......
End select

Since I have different of these cases I wonder if it is possible to use a
variable as follows:


Dim CaseVariable as variant
Set CaseVariable= "ABC"
Select Case Cells(i, 8)
Case CaseVariable
......
End select

So far I cannot get this working. Is it possible? Please advise.