Updating formulas - or how to find the column name


#1

I’m working at updating my excel document again and I’ve run up against another wall. I need to get ahold of the column name (A-Z, AA-AZ, etc) to update the formulas.

I got around the initial need by using column/row syntax for looping through while creating my new columns. However when setting/updating the newly created columns cells that have formulas I need the column name so I can do one of the following.

(Examples)
destinationCell.Formula = “=SUM(” + destinationCell.ColumnName + “9:” + destinationCell.ColumnName + “11)”

or destinationCell.Formula=sourceCell.Formula.Replace(sourceCell.ColumnName,destinationCell.ColumnName)

In my particular case the column only refers to the cells within itself for formulas.

Any ideas?

Thanks for any help.


#2

I found it right after posting. Cells.ColumnIndexToName(destinationCell.Column)

If I could make a suggestion it would be helpful just to have a helper property at that level that gets the columnname for you.

Thanks!