LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 735
Default DEC2HEX

There is a DEC2HEX function in xl2007
http://msdn.microsoft.com/en-us/library/bb239275.aspx

and in the analysis toolpak addin for xl2003
http://office.microsoft.com/en-us/ex...090541033.aspx

--

Regards,
Nigel




"Francis Ang" wrote in message
...
I am trying to convert Decimal to Hex and found the following codes in
Excel
community website. The function works fine except that when I enter
decimal
values such as 112 or 160 or 208 nothing happens; there is no hex value
returned. These are the only numbers that I noticed so far, there could
be
more!

Any reason for this?

Any help would be greatly appreciated.

Public Function Decimal_To_Hex(ByVal vntDecimal_Value As Variant) As
String
'----------------------------------------------------------------------------
' Experts Exchange Question:
' Home \ All Topics \ Applications \ MS Office \ Excel
'
'http://www.experts-exchange.com/Applications/MS_Office/Excel/Q_21547447.html
' Creating Column that does hexidecimal math
'
' Copyright (c) 2005 Clearlogic Concepts (UK) Limited
' N.Lee [
http://NigelLee.info ] - 1 September 2005
'----------------------------------------------------------------------------
Dim intHex_Value As Integer
Dim intLoop As Integer
Dim vntDec_Value As Variant
Dim strReturn As String

On Error GoTo Err_Decimal_To_Hex

If Len(vntDecimal_Value) 14 Then
strReturn = "* ERROR *"
Else
strReturn = ""
vntDec_Value = CDec(vntDecimal_Value)

For intLoop = Len(vntDecimal_Value) - 1 To 0 Step -1
intHex_Value = Int(vntDec_Value / (16 ^ intLoop))
vntDec_Value = vntDec_Value - (intHex_Value * (16 ^ intLoop))
strReturn = strReturn & Hex(intHex_Value)
Next intLoop
End If

Exit_Decimal_To_Hex:

On Error Resume Next

If Left$(strReturn, 1) = "0" Then
strReturn = StrReverse(strReturn)
strReturn = StrReverse(Left$(strReturn, InStr(strReturn, "0") - 1))
End If

Decimal_To_Hex = strReturn

Exit Function

Err_Decimal_To_Hex:

On Error Resume Next

strReturn = "* ERROR *"

Resume Exit_Decimal_To_Hex

End Function


 
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
DEC2HEX with VBA in Excel 2007 Rishi Setting up and Configuration of Excel 5 May 8th 08 11:59 PM
Hex2Dec and Dec2Hex don't work Robin Clay[_4_] Excel Programming 13 May 8th 08 07:13 PM
Embedded Dec2hex help needed mogulboy Excel Worksheet Functions 2 August 2nd 07 05:52 PM


All times are GMT +1. The time now is 11:58 PM.

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"