Most suggestions in this thread wont work for columns beyond 26,
and you should make it a habit to try to make your code as universal
and bullitproof as possible. As you'll probably be using it more often,
wrap it in a function.
usage like
?debug.print
columnletter(activesheet.specialcells(xlCellTypeLastcell).column)
'This one is "future proof",
'(if MS ever decides to allow more than 256 columns)
Function ColumnLetter(ByVal colNum As Long) As String
Do
ColumnLetter = Chr$(65 + (colNum - 1) Mod 26) & ColumnLetter
colNum = (colNum - 1) \ 26
Loop While colNum > 0
End Function
'This one is marginally faster but limited to two letter combinations.
'(which works for all current versions).
Function Column_Letter(ByVal colNum As Long) As String
colNum = (colNum - 1) Mod 256
If colNum > 25 Then Column_Letter = Chr$(64 + colNum \ 26)
Column_Letter = Column_Letter & Chr$(65 + colNum Mod 26)
End Function
hth
--
keepITcool
|
www.XLsupport.com | keepITcool chello nl | amsterdam
Bill Sturdevant wrote :