Code in excel

hi friends. I have two excel files. in first have several columns and each column two codes. in second excel have several columns and in each column several codes. the codes in the first excel that are in one column could not be together in the second excel in one column. Now the bot should check and if in the second excel find conflict then report an error in the column below. how should i develop I will be grateful if you help me.

Hello @a.hezardastan, try something like this:

Read Excel File 1 into DataTable1
Read Excel File 2 into DataTable2

For Each Row in DataTable1
Get Code1 and Code2 from the current row

For Each Row in DataTable2
    Check if Code1 or Code2 exists in any column of the current row
    If conflict is found
        Log the conflict or write it to a report (e.g., Excel file)
    End If
End For Each

End For Each

Cheers! :slight_smile:

1 Like

Thanks. i know that bro but how should i write it in for each and if aktivitat.
how should i write in if Code1 or Code2 exists in any column of the current row

I think this might work:

For Each Row (row1) in dtExcel1
Assign
Boolean isConflictFound = False

For Each Row (row2) in dtExcel2
    Assign
        Boolean isCode1InRow2 = False
        Boolean isCode2InRow2 = False

    For Each Column (col) in dtExcel2.Columns
        If row2(col).ToString.Equals(row1("Code1").ToString, StringComparison.OrdinalIgnoreCase) Then
            Assign
                isCode1InRow2 = True
        End If

        If row2(col).ToString.Equals(row1("Code2").ToString, StringComparison.OrdinalIgnoreCase) Then
            Assign
                isCode2InRow2 = True
        End If
    End For Each Column

    If isCode1InRow2 And isCode2InRow2 Then
        Assign
            isConflictFound = True
        Log Message
            Message: "Conflict found in Excel2 for Code1 and Code2 in Excel1 row: " + row1("YourRowIdentifierColumn").ToString
    End If
End For Each Row (row2)

If isConflictFound Then
    // Here you can take any actions needed when a conflict is found in Excel2 for a row in Excel1.
    // For example, you can write it to a report or perform other actions.
End If

End For Each Row (row1)

Cheers! :slight_smile:

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