If value is not found in a table, send an email

Hi!

I have datatable (called supplierNamesDT) with 2 columns (called “Name” and “Address”).

I search each row, and if my variable (called: suppliesToLookup) matches what is on the column 1 (Name) on that row, then I will open a link that is in column 2 (Address).

However, I also want to know, if the value in the variable (supplierToLookUp) is not found in the table at all. With each row-structure I have now, it would send me a message for each row it does not find the value. I just want ONE note when it has gone through the WHOLE TABLE and has not found that value.

Current situation:

Any ideas?

BR
Johanna

Hi Johanna,

Declare a boolean variable (say boolFlag)
assign it as false in Else part of your condition
Also assign it as true in Then part of your condition

Finally,
if the boolFlag = False - Send Mail atlast
if boolFlag = true - Needn’t send

1 Like

Thank you, that worked! Just had to remember to put the second if outside the “for each row”-loop (first try I did not notice that one) :slight_smile:

Hi!

Actually realised it was only working because the value I was looking for was on the last row.

If it is not the last row, my automation will go through the whole Excel, find the right value somewhere in the middle, and then if the last row is not the one it was looking for it will also send me the email “not found” (because it did not find it on the last row).