If condition to match a keyword

Hey there,

My source data is an Excel File that contains multiple sheets. I have done the “Get Workbook Sheets” and got the sheetnames. But the problem here is I cannot specify the name of the Sheet because it will change with each Excel.

The Keyword that I need to match is “Machine”. But the sheet might be named as “Machine - 123” or “Machine 1130”.

I’ve tried “If” condition as below:

if

But it’s not working. Can anyone help me to point the mistake?

Thank you!

@remy223 - pls try this - allSheets.ToLower.Trim.Contains(“machine”)

Hey there,

Thanks for the reply!
I’m getting the below error. When i do the “Get Workbook Sheets” it is saved as List.

image

excel “Get workbook sheets” activity save the output to a list<string> variable ex: gwSheets. gwSheets.contains(“Machine”) will work without any issues.

please write gwSheets log in both if / else conditions and verify the sheet names.

Yup, this is the one that i used as per screenshot in the question above. But i still unable to match the condition.

pls write the sheet name in both if/else states and share the results logs.

you can try -

allSheets.ToArray().Any(Function(x) x.ToString().ToLower.Contains(“machine”))

1 Like

Hello @remy223, Try following condition in IF:

allSheets.Any( l => l.Contains("Machine") )

Cheers