LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 5,441
Default formulat to convert base 32 to decimal?

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Translation Formulat Entry Rob Excel Worksheet Functions 0 June 6th 07 02:54 PM
convert decimal number to time : convert 1,59 (minutes, dec) to m agenda9533 Excel Discussion (Misc queries) 8 January 20th 05 10:24 PM
convert a nine digit number to base 32 Wildman Excel Worksheet Functions 14 January 18th 05 01:21 AM
how do I convert numbers to a different base in Excel? henry Excel Worksheet Functions 1 January 14th 05 02:07 PM
Convert Works 6.0 data base to Excel? CarolER New Users to Excel 1 January 8th 05 05:35 PM


All times are GMT +1. The time now is 11:57 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"