[AccessD] Manipulating Excel Cells

Stuart McLachlan stuart at lexacorp.com.pg
Wed Feb 1 16:49:07 CST 2006


On 1 Feb 2006 at 13:41, John Colby wrote:
> 
> So what I was looking for (and found) was a syntax for using column letters
> instead of the silly cell(31,29).  What column is 29?  What "number" is
> column BA?  

In case you need it in future:

Function ColNumToName(ColNum As Long) As String
   If ColNum < 27 Then
       ColNumToName = Chr$(ColNum + 64)
   Else
       ColNumToName = _
          Chr$(Int((ColNum - 1) \ 26) + 64) _
          + Chr$((ColNum - 1) Mod 26 + 65)
   End If
End Function

Function ColNameToNum(ColName As String) As Long
If Len(ColName) = 1 Then
ColNameToNum = Asc(UCase$(ColName)) - 64
Else
ColNameToNum = 26 * (Asc(UCase$(Left$(ColName, 1))) _
     - 64) + Asc(UCase$(Right$(ColName, 1))) - 64
End If
End Function
-- 
Stuart





More information about the AccessD mailing list