How to check if a cell contains keywords?

excel

#1

Hi there,

I am trying out below:

if (remarks = “Special Container Handling detected”)
then {copy into excel}
else {do nothing}

however, for the remarks column, i have multiple various forms as below:

  1. Shipment/Conn pending vetting/confirmation
    Special Container Handling detected
    VGM Pending Confirmation detected

  2. Special Container Handling detected

  3. Special Container Handling detected
    VGM Pending Confirmation detected

  4. so on and so forth . . .

I want to extract all remarks that contains the text "Special Container Handling detected"
i.e. as long as the cell contains the text, i want to copy it to another sheet.

how do i go about doing it?

Thanks!


#2

https://www.tutorialspoint.com/vbscript/vbscript_instr_function.htm

hope my inputs are useful


#3

Hi rkelchuri,

Apologies, but i am relatively new to VBA.
Seems like the post is for excel macros?
is there a way i can do it within uiPath instead of writing macros and executing them in excel?

Thanks!


#4

Yes it is possible by using UiPath. again you will adopt VB scripting to validate the string values for special characters on the cell value.

let’s consider same example what you explained.
if (remarks = “Special Container Handling detected”)
then {copy into excel}
else {do nothing}

remarks is a string which is going to read cell value and store in it.
TestPos = InStr(4, SearchString, SearchChar, CompareMethod.Text)
This TestPos will return true or false binary values 0 or 1.
https://msdn.microsoft.com/en-us/library/8460tsh1(v=vs.90).aspx

Hope my inputs are useful


#5

You can try this simple condition instead -

if (remarks.Contains("Special Container Handling detected”))
then {copy into excel}
else {do nothing}

For more details Contains please refer -https://msdn.microsoft.com/en-us/library/dy85x1sa(v=vs.90).aspx

Regards,
Amrita