How to get not equal to

i have 2 excel sheets with
(sheet1) (sheet2)
empid name email empid name
123 abc abc@gmail 123 abc
345 def jkl@gmail 899 jkl
567 ghi ghi@gmail 567 ghi

i need to extract jkl@gmail.com from sheet2
i tried with not equal to(i.e < >) i got jkl along with that i got others names also

Where are you using <>, whats is your condition? Comparing two sheets?

you can compare two datatable rows with empid

if dt1 empid <> dt2 empid — get dt2.row(email)

1 Like

i am not getting its working same as <>

ya comparing two sheets

sheet1
Empid Name
123 abc
234 def
345 ghi
sheet2
Empid Name
123 abc
234 def
678 xyz
890 sdf

output
Emp_id Name
678 xyz
890 sdf

if(dt1.row(0).toString<>dt2.row(0).toString) i didn’t get for isNot as well iam getting not matched value too

1 Like

if you want to compare rows, not the uniqye ids, you can do the following way

bool isRowEqual = rowDt1.ItemArray.SequenceEqual(rowDt2.ItemArray)

I am not getting

Thanks,
Vinay

Hello,

If you want to compare only empid then you need to target the ‘datacells’, on your if you just take the row themselves.

it should be : if(dt1.rows(0)(0).toString<>dt2.row(0)(0).toString) to get the first cell of the first row.
However, it is more suitable to do it inside a for each row using the variable “row” and taking its first children : row(0).tostring.

If you want to compare all the row then you should use Sequence equal as @vvaidya said.

In your case it would be Dt1.Rows(0).ItemArray.SequenceEqual(Dt2.Rows(0).ItemArray).

Cheers.

Column Count won’t be same in my case :frowning:
Is there any way to find not equal values
sheet1
Empid Name 1 2
123 abc
234 def
345 ghi
sheet2
Empid Name Dept
123 abc
234 def
678 xyz
890 sdf
789 tyu

output
Emp_id Name
678 xyz
890 sdf
789 tyu