Formatting Cells - Hex Values

L

LordHog

Hello,

I am trying to add a Custom format code that has the following
format code:

"0x"00000000

This works well if the numeric value only contains values from 0-9
(e.g., 1111, 12545, etc), but will fail if the input contains any
character values (e.g., 'A', 'F', etc). So, if I entered FFFF0000,
this would be displayed at 0xFFFF0000. I understand the reason why as
Excel is treating it as a text string, but is there a way to get Excel
to format the cells so I can enter characters of [0-9a-fA-F]???

Thanks,
Mark
 
G

GS

Hello,

I am trying to add a Custom format code that has the following
format code:

"0x"00000000

This works well if the numeric value only contains values from 0-9
(e.g., 1111, 12545, etc), but will fail if the input contains any
character values (e.g., 'A', 'F', etc). So, if I entered FFFF0000,
this would be displayed at 0xFFFF0000. I understand the reason why as
Excel is treating it as a text string, but is there a way to get Excel
to format the cells so I can enter characters of [0-9a-fA-F]???

Thanks,
Mark

Set the NumberFormat to 'Text' and the cell will display exactly what
you enter, exactly the way you enter it!
 
L

LordHog

  I am trying to add a Custom format code that has the following
format code:
"0x"00000000

  This works well if the numeric value only contains values from 0-9
(e.g., 1111, 12545, etc), but will fail if the input contains any
character values (e.g., 'A', 'F', etc).  So, if I entered FFFF0000,
this would be displayed at 0xFFFF0000.  I understand the reason why as
Excel is treating it as a text string, but is there a way to get Excel
to format the cells so I can enter characters of [0-9a-fA-F]???
Thanks,
Mark

Set the NumberFormat to 'Text' and the cell will display exactly what
you enter, exactly the way you enter it!

--
Garry

Free usenet access athttp://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc

Garry,

Thanks, but this I already knew this. I could do this, but I would
rather not. In the end, I want to perform calculation on the cell and
I would rather not busy the code to extract the data from the cell
(e.g., RIGHT(), LEFT(), etc).

Mark
 
G

GS

LordHog explained on 11/8/2011 :
  I am trying to add a Custom format code that has the following
format code:
"0x"00000000

  This works well if the numeric value only contains values from 0-9
(e.g., 1111, 12545, etc), but will fail if the input contains any
character values (e.g., 'A', 'F', etc).  So, if I entered FFFF0000,
this would be displayed at 0xFFFF0000.  I understand the reason why as
Excel is treating it as a text string, but is there a way to get Excel
to format the cells so I can enter characters of [0-9a-fA-F]???
Thanks,
Mark

Set the NumberFormat to 'Text' and the cell will display exactly what
you enter, exactly the way you enter it!

--
Garry

Free usenet access athttp://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc

Garry,

Thanks, but this I already knew this. I could do this, but I would
rather not. In the end, I want to perform calculation on the cell and
I would rather not busy the code to extract the data from the cell
(e.g., RIGHT(), LEFT(), etc).

Mark

Could you not use the HEX() function to convert the value when you need
to calc? For example, FFFF0000 converted to a decimal is 255,255,0,0
which includes comma delimiters. Similarly, 0xFFFF0000 converted to a
decimal is 0,255,255,0,0! These values were returned using the
following VB custom function...

Function Hex2Dec(HexString As String) As String
' Builds a delimited DecString from a source HexString
Dim i As Long
For i = 1 To Len(HexString) Step 2
Hex2Dec = Hex2Dec & "," & CStr(Val("&H" & Mid(HexString, i, 2)))
Next i
Hex2Dec = Mid(Hex2Dec, 2)
End Function

This function does the same as the HEX2DEC function in the Analysis
Toolpak adding. I added the delimiter feature for use in a client
project so you can remove that part to return only digits if need be.
In this case, the returned values would be 25525500 and 025525500,
respectively.

Maybe if you explain what you're trying to accomplish in more detail
someone will be able to offer better help!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top