Article ID: 135635
Article Last Modified on 6/11/2007
Function baseconv(InputNum, BaseNum)
Dim quotient, remainder As Single
Dim answer As String
quotient = InputNum ' Set quotient to number to convert.
remainder = InputNum ' Set remainder to number to convert.
answer = ""
Do While quotient <> 0 ' Loop while quotient is not zero.
' Store the remainder of the quotient divided by base number in a
' variable called remainder.
remainder = quotient Mod BaseNum
' Reset quotient variable to the integer value of the quotient
' divided by base number.
quotient = Int(quotient / BaseNum)
' Reset answer to contain remainder and the previous answer.
answer = remainder & answer
Loop
baseconv = Val(answer) ' Convert answer variable to a number.
End Function
The function should be typed in a worksheet cell as follows:
=baseconv(InputNum, BaseNum)For example, the following call to the baseconv function:
=baseconv(100,2)returns the following value in the cell:
1100100
user-defined functions
user-defined functions
Additional query words: 5.00a 5.00c 8.00 97 98 XL98 XL97 XL7 XL5 custom XL
Keywords: kbhowto kbprogramming kbdtacode KB135635