For each Datatable _002

Hello guys,

i have a “Column not found” error in For each Datatable given below

Here 46th column is a remark column.

I have used the same for each just above this error but iam not getting any error on that

It clearly means col 46 does not exist in this DataTable. Are you accessing columns using index?

Can you share a ss of col or linq you are using ?

The “Cannot find column 46” error usually means the column doesn’t exist at the specified index. A couple of things to check:

  1. Column Index: Ensure you’re using the correct index. Columns are zero-based, so the 46th column should be index 45.
  2. Check Column Names: Use a For Each loop to print out the column names and confirm that “remark” exists in your DataTable.Example:
For Each col In YourDataTable.Columns
    Log Message: col.ToString()
Next
  1. Column Presence: Before accessing the column, check if it exists:
If YourDataTable.Columns.Contains("remark") Then
    ' Access the remark column
Else
    ' Handle missing column
End If
  1. Dynamic Columns: If the column names change, consider using the column name instead of the index.

@MohammedShabbir

But its there iam using that column also

@Monali_Vekariya

  1. The column exists on 46th index.

  2. For testing i have used a separate for each loop, it is going through and also i have used a for each just above this error that is also passing through any error.

  • The Read Range before this loop is different or missing headers
  • UiPath only reads up to the last non-empty column, so empty columns are skipped
  • You might be using a wrong DataRow variable inside nested loops
  • Column index starts from 0 → column 46 = index 45

Add a Write Line(dt.Columns.Count.ToString) to confirm.
Use the column name instead of index:

CurrentRow("Remark").ToString

If you want, share your Read Range, DataTable name, and the exact line where you access the column — I can help you pinpoint it.

Hi @Gokul_Murali

UiPath is not reading all columns from your Excel file.Even though Excel shows column AU (47th column)…

UiPath is reading less columns, maybe 40 or 43.

Can you try to read excel with Range: “A1:AU5000”. Lets test with this.
After Read Range, Add a Log Message:"Colun count = " + dt.Columns.Count.ToString.
Then we will come to know if we read all cols are not.

Mostly it will read all columns then. Can you give a try and let me know