Switch with Excel

Hello everyone, I would like to use the Switch application to check whether a certain value is in an Excel cell, but I am failing. The value is in a cell and is part of a text.
I have solved it as follows using an if condition, but this does not work with switch.

@NHoe - you can’t use in the cases but you can build the switch expression differently so that you can use hard-coded values in cases …

Check this…

Hello, thank you for the answer, but I can’t do much with it. How can you basically read out an Excel table in the switch, since it is output as a string instead of an integer?

@NHoe
(Kindly note: a switch - Stringtype, is not evaluating the code statement, it is taking the statement as value - does mean: myVar.ToUpper = “ABC” is using the statement string for match)

in such scenarios we do implement a mapping functionality from value to values which we do use in the cases.

it can be done e.g. with regex:
grafik

We do see that Sim can match into 2 scenarios, and requires an additional handling on checking if its contained or entire column value. But in general we can handle

Another approach (similar driven) is about writing the mapping check and returning a customized harmonized value, later used in switch.