T
Todd Huttenstine
In run mode when you are pressing F8 to run each line of code line by line
you can usually hold your curssor over a variable and it show you the value.
Well why is it not doing that on the following code? I got this code off of
http://www.rb-ad.dircon.co.uk/rob/excelvba/tips/index.htm
Dim intTemp As Integer
Dim intInt As Integer
Dim intMod As Integer
Dim column_number
Dim COLUMN_LETTER
column_number = Worksheets("Sheet1").Range("A10").Value
' return error if column number is not a number
'If Not IsNumeric(column_number) Then _
' COLUMN_LETTER = CVErr(xlErrRef): Exit Function
' if column number is a range then only consider
' the first cell in the range
If TypeName(column_number) = "Range" Then
If column_number.Cells.Count > 1 Then _
intTemp = column_number.Cells(1, 1).Column _
Else intTemp = column_number.Column
Else
intTemp = column_number
End If
' if column number is illegal then return an error
'If intTemp > 256 Or intTemp < 1 Then _
' COLUMN_LETTER = CVErr(xlErrRef): Exit Function
' divide column number by 26. Remainder
' is the second letter
intMod = intTemp Mod 26
' if no remainder then fix value
If intMod = 0 Then
intMod = 26
intTemp = intTemp - 26
End If
' first letter
intInt = intTemp \ 26
' put it together
If intInt = 0 Then _
COLUMN_LETTER = Chr(intMod + 64) Else _
COLUMN_LETTER = Chr(intInt + 64) & Chr(intMod + 64)
MsgBox COLUMN_LETTER
MsgBox column_number
you can usually hold your curssor over a variable and it show you the value.
Well why is it not doing that on the following code? I got this code off of
http://www.rb-ad.dircon.co.uk/rob/excelvba/tips/index.htm
Dim intTemp As Integer
Dim intInt As Integer
Dim intMod As Integer
Dim column_number
Dim COLUMN_LETTER
column_number = Worksheets("Sheet1").Range("A10").Value
' return error if column number is not a number
'If Not IsNumeric(column_number) Then _
' COLUMN_LETTER = CVErr(xlErrRef): Exit Function
' if column number is a range then only consider
' the first cell in the range
If TypeName(column_number) = "Range" Then
If column_number.Cells.Count > 1 Then _
intTemp = column_number.Cells(1, 1).Column _
Else intTemp = column_number.Column
Else
intTemp = column_number
End If
' if column number is illegal then return an error
'If intTemp > 256 Or intTemp < 1 Then _
' COLUMN_LETTER = CVErr(xlErrRef): Exit Function
' divide column number by 26. Remainder
' is the second letter
intMod = intTemp Mod 26
' if no remainder then fix value
If intMod = 0 Then
intMod = 26
intTemp = intTemp - 26
End If
' first letter
intInt = intTemp \ 26
' put it together
If intInt = 0 Then _
COLUMN_LETTER = Chr(intMod + 64) Else _
COLUMN_LETTER = Chr(intInt + 64) & Chr(intMod + 64)
MsgBox COLUMN_LETTER
MsgBox column_number