IF Excel Cell contains an item in an array type of string, then send hotkey


I have searched and cannot find a scenario specific to mine, so I apologize if there is a solution out there already.

What I am trying to accomplish:

Using a For Each Excel Row, check the value of CurrentRow.ByIndex(0). If that cell value contains any of the strings in a variable array of type string (lets call is arrString), then send a hotkey.

I tried using an else if statement, and then typing " CurrentRow.ByIndex(0).contains(arrString)" but that obviously doesn’t work.

I have seen posts say to use a for loop - for each value in Array, if arrString.contains(value), set Boolean to true -

I am unable to convert that to dealing with an excel cell value, though

I appreciate the help and guidance!

Hi @Sc100
often it helps us when some sample data or more details are shared with us.

give a try at:
arrValue.Any(Function (x) CurrentRow.ByIndex(0).toString.ToUpper.Contains(x.ToUpper))


That, my friend, did it for me! Thank you!

arrValue.Any(Function (x) CurrentRow.ByIndex(0).toString.ToUpper.Contains(x.ToUpper))

Could you explain what “Function(x)” does in that statement? I just want to be able to understand as well as I can.

Also, would I use this same line if the array contained integers? If not, how would the line need to look?

I will heed your friendly suggestion to post as much information as possible moving forward.

Thank you again!

it is about LINQ on what we had used:

an integer array we would convert to strings

arrIntValue.Any(Function (x) CurrentRow.ByIndex(0).toString.Contains(x.ToString))
1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.