How to Find out last column in Excel

Hi all,

Im trying to find the last column of an excel where the headers are not from first row.Can you please hele me how to do this.

Attaching screenshot for reference

Hi @Aswini

Datatable.Columns(dataTable.Columns.Count - 1)

It will give the last column name.

Hope it helps!!

Hi @Aswini

Check on this thread

I hope it helps!!

its not giving me the right column count.Could be because of merged cells. Its giving last colum as T instaed of U.Any way to get right column name

Have you used read range workbook activity to store the Excel value in datatable.
Then use assign activity and create a string variable.
In that give the above expression that I have given in replies.

Hope you understand!!

Hi @Aswini ,

Could you let us know what is the reason for finding out the Last Column Index ?

If there are merged Cells, when reading the Excel sheet as a Datatable, it will consider the data to be in the First Cell Of the Cells that were merged (Could also be observed when Unmerged manually as well).

Depending on the requirement we can use the Datatable Columns Count itself as the Last Column Index as already suggested above or if not possible with this, we would need to understand why it is not possible, so that we can suggest alternatives accordingly.

hey all the data is starting from Column C so the Column count its giving 19 i guess

@Aswini ,

Could you provide the Range value in the Read Range activity as "A1" and check if it gives the correct column index.

if we want to use any variable instead of A or B according to column in excel.how can we do that

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