Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
hex to decimal
Hi Keivn,
A possible way: Private Function HexToDec#(BinVal$) Dim i%, Lg% Lg = Len(BinVal) For i = Lg To 1 Step -1 HexToDec = HexToDec + (Nb(Mid(BinVal, i, 1)) * (16 ^ (Lg - i))) Next i End Function Private Function Nb%(i$) Const Chain$ = "0123456789ABCDEF" Nb = Val(InStr(1, Chain, i, 1) - 1) End Function Sub Test() ActiveCell = HexToDec(ActiveCell) End Sub MP "Keivn Green" a écrit dans le message de ... I need a macro that will convert a hex number to decimal. I've tried activecell= cdec(activecell) with no luck... I want to do it without having a formula in the cell do it. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
hex to decimal
yes Tom, good remark and very simple.
Regards, MP "Tom Ogilvy" a écrit dans le message de ... for less than 8 hexidecimal digits hexnumber = "A1B5" ActiveCell.Value = clng("&H" & hexnumber) -- Regards, Tom Ogilvy "Michel Pierron" wrote in message ... Hi Keivn, A possible way: Private Function HexToDec#(BinVal$) Dim i%, Lg% Lg = Len(BinVal) For i = Lg To 1 Step -1 HexToDec = HexToDec + (Nb(Mid(BinVal, i, 1)) * (16 ^ (Lg - i))) Next i End Function Private Function Nb%(i$) Const Chain$ = "0123456789ABCDEF" Nb = Val(InStr(1, Chain, i, 1) - 1) End Function Sub Test() ActiveCell = HexToDec(ActiveCell) End Sub MP "Keivn Green" a écrit dans le message de ... I need a macro that will convert a hex number to decimal. I've tried activecell= cdec(activecell) with no luck... I want to do it without having a formula in the cell do it. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Set automatic currancy decimal without entering the decimal? | Excel Worksheet Functions | |||
Subtracting two 2-decimal place numbers gives result 13-decimal places? | Excel Worksheet Functions | |||
Batch converting CSV files from comma-decimal to period-decimal | Excel Discussion (Misc queries) | |||
Converting 2-place decimal value to floating point decimal number with leading zero | Excel Discussion (Misc queries) | |||
FIXED 2 DECIMAL PLACES, MUST ENTER ALL ZEROES AFTER DECIMAL POINT. | Excel Discussion (Misc queries) |