How Can I Update an Excel Column by Name?

How can I write to an Excel Sheet using the column name instead of the letter.
The image below illustrates my current method (Range= “B” + rowNumber.ToString()) .

Instead of "B + rownumber.ToString(), I need to use a column name (e.g. “ESS”). This is needed because the “ESS” may move as new columns are added to the excel worksheet.

A sample workflow or alternatively, a statement to put in the Range property would be appreciated. An image of the ExcelWriteCell activity would be helpful too.

Note: The discussion from Update value to an existing column in excel: requests a similar answer, but that answer did not work for me.

grafik

dtData.Columns
DataColumnCollection(2) { [Column1], [ESS] }
dtData.Columns("ESS").Ordinal
 1
Uipath.Excel.Helpers.ExcelUtilities.ConvertColumnIndexToColumnLetter(dtData.Columns("ESS").Ordinal + 1)
"B"

thank you. Can you illustrate this by showing how to implement this in the GUI (ExcelWriteCell ) activity?

not sure if you are asking for this as it just variables similar to your example:

grafik

Uipath.Excel.Helpers.ExcelUtilities.ConvertColumnIndexToColumnLetter(dtData.Columns("ESS").Ordinal + 1)

grafik

Thank you!!!
For future reference:

@ppr provided an elegant solution for updating an excel value using the column name.

Again, thank you!

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