Loop through entire row and check if string contains specific word

I have a list of full address in sheet 1 and list of all the province in sheet 2.
What I want is to loop through the entire row of address then checks if the address contains a specific province from my list then write that province besides the address.

  1. First I read the range of the address and province and store in data table

image

  1. Then I loop through province row using for each row data table and assign it to “sample” variable

image

  1. After that I loop through the address row and checks if my address contains a province in my list

Like this:

CurrentRowData.Item(“Address”).ToString.Contains(sample).Equals(True)

The problem is, it doesn’t give me the result I want.

@Shoji welcome to the Comunity

VariableName.Rows.Contains(“SpecificContent”)

image

I provided some images, can you look at it again? thanks

Hi,

I think it’s necessary to consist of double loop as the following. Can you try this?

image

Regards,

Hello, thanks for the comment. I tried it but it doesn’t satisfy my condition.

@Shoji

try this once

CurrentRow.Item(“Address”).ToString.Contains(“sample”) = True

Hi,

If I understood your requirement correctly, the following mock sample will work. Can you try this?

Sample20230205-3L.zip (3.1 KB)

Regards,

Hello, it’s the same result

CurrentRow.Item("Address").ToString.Contains(CurrentRow.Item("Province").ToString.Trim) = True
1 Like

Thank you, this is the output I’m looking for.

1 Like

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