Link a code of two different excel

good afternoon well I want you to detect this excel code in the column “Cultivation”

and can get the value in this other excel

but as automatically as possible, because let’s say in the “crop” column it changes to organic lucuma and so I want it to detect in the other excel what is the code to register

My goal is to detect the code you have to write and register it in Excel

any ideas thank you very much

@borismh give this a look… https://docs.uipath.com/activities/docs/filter-and-delete-rows-in-csv-files

@Jarzzz
I think that doesn’t solve my problem

When you say detect code, do you mean text?


Also there is no “Cultivation” column in either of the images you shared

2 Likes

@Jarzzz

if, for example, I read the first excel with “read range” then I pass it through a “for each row” and with “get row item” I extract the value from the “crop” column then I put it in a “if” condition

then with what is written in the column “crop” I must detect its code that is in another excel, but I want to make it dynamic since if it changes the value in the column “crop” I can detect which is its correct code

and finally write that code in the initial excel

@Jarzzz

@Palaniyappan @Dave

help

This doesn’t make sense… You are mentioning Columns that dont exists.

Am I understanding correctly? You are looking to see if a value from Excel 1 Column “Cultvo” is found in Excel 2?

Also what does Code mean? Is Code the string found in the excel cell or does Code mean a function used to populate the cell?

Hi @borismh I am also struggling a little bit to understand which part you are struggling with. I will do my best to guess so please correct me if I am wrong. You want to read the excel worksheet containing all the data, iterate through each row in the data and read the value in the “Cultivo” column. Then you want to use that value to lookup the corresponding value from the lookup table found in the 2nd worksheet. I’m not sure what you’re doing with this value but i’ll assume you are writing it back to the original excel.

Based on your example you see the value is “Cacao Organico” in the “Cultivo” column, so you use the lookup to determine the value is “ESA201902” which you will then put back into the same line (i’ll put it in the “Comentarios” column)

I would do the following:

  1. Read range for the whole data worksheet to save it as a datatable i’ll call dt1
  2. Read range for the whole lookup table worksheet to save it as a datatable I’ll call LookupTable. Since your worksheet doesn’t appear to have headers, be sure to leave the ‘Add headers’ property unchecked
  3. For each row in dt1
    a. Assign LookupValue (this is a string variable) = row.item(“Cultivo”).ToString
    b. Assign ReturnedValue (this is string variable) = LookupTable.Select("[Column1] = ‘" + LookupValue + "’").FirstOrDefault().item(“Column2”).ToString
    c. Assign row.item(“Comentarios”) = ReturnedValue

The above code would result in the correct value being put into the “Comentarios” column for each row of your input data worksheet

3 Likes

@Dave

I get that it refers to an object that does not exist,

it’s fine as I did

@Dave

excel 2 where there are few values if it has a header, it is called in column 1 “alimento” and column 2 “cabecera”

@borismh - which part are you getting the error?

Also, you can change any of the column names. Just be sure to check the ‘add headers’ property in step 2 which indicates your data has headers. Then in step 3b change it to:

Assign ReturnedValue (this is string variable) = LookupTable.Select("[alimento] = ‘" + LookupValue + "’").FirstOrDefault().item(“cabecera”).ToString

1 Like

@Dave

if I already fixed it
I already left
thanks

1 Like

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