Excel Data Values Change

Good day,
I would like some assistance please I am working with excel file trying to extract data from the column there but the name of the column changed on the other excel file:
column 1:
image

Column 2:
image

This is how I am extracting the values from those columns:
image
image

It sends an error when it gets to extract on the other file since the rows(Email) are not named the same…
How can I cater or resolve this?

@Anelisa_Bolosha1

you can use the column index as well so instead of name use number like 7

cheers

1 Like

Else If row.Columns.Contains("Email ")

  • Then Assign row.item("Email ").ToString

Else if row.Columns.Contains(“Email 2”)

  • Then Assign row.item(“Email 2”).ToString

Else

  • Throw “email column not found”

Note that I respected the extra space you have after Email, not sure if that was intentional.

1 Like

Use Try Catch Block

in the Try

Assign Email - row.Item(“Email”).ToString

In the catch block

Assign Email =row.Item(“Email 2”).ToString

Irrespective of the column name - this should work

Check and let me know if you are facing any challenge

1 Like

Hi @Anil_G , how do I use it?

@Anelisa_Bolosha1

row(7).ToStirng is what you would use

cheers

This is an easier way thank you @Anil_G …it worked

1 Like

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