Function GetColumnLetter(Cell_Add As Range) As String '' e12
Dim No_of_Rows As Integer
Dim No_of_Cols As Integer
Dim Num_Column As Integer
No_of_Rows = Cell_Add.Rows.Count
No_of_Cols = Cell_Add.Columns.Count
If ((No_of_Rows <> 1) Or (No_of_Cols <> 1)) Then
GetColumnLetter = ""
Exit Function
End If
Num_Column = Cell_Add.Column
If Num_Column < 26 Then
GetColumnLetter = Chr(64 + Num_Column)
Else
GetColumnLetter = Chr(Int(Num_Column / 26) + 64) & Chr((Num_Column Mod 26) + 64)
End If
End Function
(function() {
function Chr(ascii) {
return String.fromCharCode(ascii);
}
function GetColumnLetter(cellAddress) {
var numOfRows = cellAddress.Rows.Count;
var numOfCols = cellAddress.Cols.Count;
if ((numOfRows != 1) || (numOfCols != 1)) {
return "";
}
var numColumn = cellAddress.Col;
if (numColumn < 26) {
return Chr(64 + numColumn);
} else {
return Chr(parseInt(numColumn / 26) + 64) +
Chr((numColumn % 26) + 64);
}
}
// var oSheet = Api.GetSheet("Sheet1");
var oSheet = Api.GetActiveSheet();
var oRange = oSheet.Selection;
var colLetter = GetColumnLetter(oRange);
oRange.SetValue(colLetter);
})();