Here is some code that I use - you might find it useful - it finds the column index of a named column assuming the heading is in the top row - it will need some tweaking to do exactly what you want (I am using JScript and have defined some constants etc):
//looks in the top row for the heading provided and returns the column index (zero based)
function findColumnHeading(name, table) {
table.WaitProperty("Exists", true, MEDIUM_LENGTH_TIMEOUT);
table.WaitProperty("VisibleOnScreen", true, MEDIUM_LENGTH_TIMEOUT);
var numColumns = table.ColumnCount;
for (var i = 0; i < numColumns; i++) {
if (table.Cell(0, i).contentText == name) {
return i;
}
}
}