Calculate the text column title for Excel when using OLE and LotusScript

This code will return the correct column title letters when you pass the total number of desiried columns. For example the last column letters for a spreadsheet containing 44 columns would be "AR". You would append the row count to those letters to get the last cell in the spreadsheet (if so desired)
LotusScript


Function CalculateRangeBounds (ColumnCount As Long) As String
	
	' Used to calculate the column labels for the number of columns (i.e. 44 columns = AR )
	
	Dim AlphabetArray(1 To 26) As String
	AlphabetArray(1) = "A"
	AlphabetArray(2) = "B"
	AlphabetArray(3) = "C"
	AlphabetArray(4) = "D"
	AlphabetArray(5) = "E"
	AlphabetArray(6) = "F"
	AlphabetArray(7) = "G"
	AlphabetArray(8) = "H"
	AlphabetArray(9) = "I"
	AlphabetArray(10) = "J"
	AlphabetArray(11) = "K"
	AlphabetArray(12) = "L"
	AlphabetArray(13) = "M"
	AlphabetArray(14) = "N"
	AlphabetArray(15) = "O"
	AlphabetArray(16) = "P"
	AlphabetArray(17) = "Q"
	AlphabetArray(18) = "R"
	AlphabetArray(19) = "S"
	AlphabetArray(20) = "T"
	AlphabetArray(21) = "U"
	AlphabetArray(22) = "V"
	AlphabetArray(23) = "W"
	AlphabetArray(24) = "X"
	AlphabetArray(25) = "Y"
	AlphabetArray(26) = "Z"
	
	If ColumnCount <= 26 Then
		CalculateRangeBounds = AlphabetArray(ColumnCount)
	Else
		Dim FirstLetter As String
		FirstLetter = AlphabetArray(Left$((ColumnCount / 26) , 1 ))
		
		Dim SecondLetter As String
		Dim ModValue As Variant
		ModValue =  ColumnCount Mod 26
		SecondLetter = AlphabetArray(ModValue)
		
		CalculateRangeBounds = FirstLetter & SecondLetter
		
	End If
	
End Function

Posted by fbrefere001 on Thursday August 8, 2002