Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Greetings all. I am trying be able to use something akin to LIKE in a case
statement. I need to set the value of a variable, "Prime" depending on whether cell B2 contains certain values, and I have tried the below, to no avail. Dim CellB2 As Variant Dim Prime As Variant CellB2 = Range("B2").Value Select Case CellB2 Case InStr(1, CellB2, "Jnet") Prime = "JNET" Case InStr(1, CellB2, "Mastec") Prime = "Mastec" Case InStr(1, CellB2, "Ivy") Prime = "Ivy" Case InStr(1, CellB2, "S&N") Prime = "S&N" Case InStr(1, CellB2, "Danella") Prime = "Danella" End Select Range("B2").Activate ActiveCell.Value = Prime Basically, if this were SQL, it would be SELECT CASE WHEN CellB2 LIKE 'Jnet' THEN 'Jnet' WHEN ..... END When I run the macro, cell B2 ends up being blank, so either I am not correctly creating the variable CellB2, or there is something wrong with the CASE. Any ideas. Thank you. Greg |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Case Statement | Excel Discussion (Misc queries) | |||
Anyone actually get Case statement to work ... ? | Excel Worksheet Functions | |||
Case Of Statement | Excel Programming | |||
Case Statement Help | Excel Programming | |||
Case statement | Excel Programming |