Public Function SpreadsheetHeaderToColumn(co As String) As Integer
co = co.ToUpper()
Dim ret As Integer = 0
For i As Integer = 0 To co.Length - 1
ret *= 26
ret += Char.GetNumericValue(co(i)) - 64
Next
Return ret
End Function
Public Function ColumnToSpreadsheetHeader(n As Integer) As String
Dim co As String = String.Empty
Dim m As Integer
' DotNet arrays/lists normally start at item(0)
' Remove the next line if your data starts at item(1)
n += 1
While n > 0
m = (n - 1) Mod 26
co = Chr(Asc("A") + m) & co
n = (n - m) / 26
End While
Return co
End Function
DigitalDan.co.uk