Home |
Search |
Today's Posts |
#2
![]()
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
You can use a UDF: the code below can be used like:
=Base2Dec("V8",32) to return 1000. PS - I'm just guessing what the letter coding for base 32 is - an extension of that used for hexadecimal??? HTH, Bernie MS Excel MVP Public Function Dec2Base(Num As Long, base As Long) As String 'converts a decimal number to the equivalent in the specified base '(base 2 to base 16). Base needs to be specified as decimal ie '8 for base 8, 16 for base 16, 2 for base 2 etc Static Digits As Variant Dim i As Long, alHolder() As Long, sTemp As String If IsEmpty(Digits) Then _ Digits = VBA.Array("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", _ "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", _ "O", "P", "Q", "R", "S", "T", "U", "V") 'check valid base: If base 32 Then Dec2Base = "Invalid base used": Exit Function 'fill holder array: i = 0 Do ReDim Preserve alHolder(0 To i) alHolder(i) = Num Mod base i = i + 1 Num = Num \ base Loop While Num 0 'build string result in base: sTemp = "" For i = i - 1 To 0 Step -1 sTemp = sTemp & Digits(alHolder(i)) Next i 'output: Dec2Base = sTemp End Function Public Function Base2Dec(Num As String, base As Long) As Variant 'converts a number in the specified base '(base 2 to base 32) into the equivalent decimal. '8 for base 8, 16 for base 16, 2 for base 2 etc Static Digits As Variant Dim i As Integer Dim myIndex As Integer Dim myStr As String If IsEmpty(Digits) Then _ Digits = VBA.Array("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", _ "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", _ "O", "P", "Q", "R", "S", "T", "U", "V") 'check valid base: If base 32 Then Base2Dec = "Invalid base used": Exit Function 'fill holder array: Base2Dec = 0 For i = Len(Num) To 1 Step -1 myStr = Mid(Num, i, 1) myIndex = Application.WorksheetFunction.Match(myStr, Digits) - 1 Base2Dec = Base2Dec + myIndex * base ^ (Len(Num) - i) Next i End Function "TMG005" wrote in message ... Is there an excel formula to convert base 32 (6digit) to decimal? |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Translation Formulat Entry | Excel Worksheet Functions | |||
convert decimal number to time : convert 1,59 (minutes, dec) to m | Excel Discussion (Misc queries) | |||
convert a nine digit number to base 32 | Excel Worksheet Functions | |||
how do I convert numbers to a different base in Excel? | Excel Worksheet Functions | |||
Convert Works 6.0 data base to Excel? | New Users to Excel |