khalid79m
01-23-2013, 06:18 AM
Function xl_Col(ByRef Col_No) As String
'returns Excel column name from value
If Col_No < 1 Or Col_No > 16384 Then Exit Function
If Col_No < 27 Then 'Single letter
xl_Col = Chr(Col_No + 64)
End If
If Col_No >= 27 And Col_No < 703 Then 'Double Letter
xl_Col = Chr(Int((Col_No - 1) / 26) + 64) & Chr(((Col_No - 1) Mod 26) + 1 + 64)
End If
If Col_No >= 703 And Col_No < 16385 Then 'Three Letters
'???????????????
End If
End Function
I have had this code for years and it works fine, now we have switched over to 2010 and we are using columns beyond "AAA" (Three letters). I cant seem to get the code right can anyone help ??:banghead:
'returns Excel column name from value
If Col_No < 1 Or Col_No > 16384 Then Exit Function
If Col_No < 27 Then 'Single letter
xl_Col = Chr(Col_No + 64)
End If
If Col_No >= 27 And Col_No < 703 Then 'Double Letter
xl_Col = Chr(Int((Col_No - 1) / 26) + 64) & Chr(((Col_No - 1) Mod 26) + 1 + 64)
End If
If Col_No >= 703 And Col_No < 16385 Then 'Three Letters
'???????????????
End If
End Function
I have had this code for years and it works fine, now we have switched over to 2010 and we are using columns beyond "AAA" (Three letters). I cant seem to get the code right can anyone help ??:banghead: