How to compare two columns in a excel with a string/int value in another file

how to compare two columns in a excel with a string/int value in another file
er.xlsx (8.7 KB)
then we will have a string in hand.we want to compare these

@Jebarohith19 Can you please elaborate on what you want to perform :sweat_smile:, Also Since you are Comparing two excel Files , We’ll need the other Excel data as well.

Try to Describr in this way :

  1. The Input.
  2. The Operation to be performed.
  3. The Output Expected.
2 Likes

we have a excelwhich contain two columns(code and recovery)
and we have two variables containing two values(codeval and recoveryval)
we need to compare code with codeval and recovery with recoveryval

@Jebarohith19 Ok, But what will be the Output? If you want to Compare you can just use an if Condition :sweat_smile:

i tried using if condition but it doesnt work
datatable.Columns(“recovery”).ToString.Contains(recoveryval)
and also i hv used for each row row(“recovery”).equals(recoveryval)

@Jebarohith19 You have to Compare all the Values in the Recovery Column with recoveryVal right? If so, then you’ll need to use a For Each row first then Check using an If Condition.

Also Can you provide the recoveryVal Value and the Column Values in Excel?

1 Like

i have uploaded a excel in the 1st post itself and recovervalue will be “sam”

@Jebarohith19 Then the For Each method should have worked :sweat_smile:

but it doesnt work i am having confidential data so tht im nt able to share . i have shared here itself is an example only
it is runtime error only it is going in the else condition everytime

@Jebarohith19 So if you want to use an Equals Operation on Two data that is being compared, it means that you are checking if two data’s are completely Equal and are one and same.

If it is not matching that means the Values are Different :sweat_smile:

@Jebarohith19 You should use the Expression this way :
row(“distfd”).ToString.Trim.ToLower.Equals(mailSplitSubject.ToString.Tolower.Trim)

You can use a Message Box inside if on both the Sides to check the Data is Equivalent or not

2 Likes

it is same only but it is not giving the right flow it ends in else condtion only
is there anything wrong with row.equals method

@Jebarohith19 if you use row('distfd").Equals(""), you will be comparing an Object with the String.

If you use row('distfd").ToString.Equals(""), you will be comparing String with a String.

Considering the Type of mailSplitSubject is String :sweat_smile:

2 Likes

it worked it is having those blankspaces i think

2 Likes

now for another column what should i do?
can i just add an and to that if condition?

@Jebarohith19 Yes you can

CompareColumn.xaml (16.6 KB) er.xlsx (8.7 KB) Other Excel.xlsx (8.0 KB)

Please check this, I have created sample of checking the code number of first excel will check the code number from second excel, If it is same code number then it will take recovervalue from second excel and write into first excel in separate column of ‘C’.

thanks satheesh

1 Like

in for each row we cant use row.contains method?