Formatting formula output

F

Fan924

Cell has the following formula
=DEC2HEX((I28-H28)/40)

The output is a hecidecimal A. I would like it to be 0A. Hex numbers
vary from 00 to FFand I neee help wiith the formatting.
 
R

Rick Rothstein

As long as your hexadecimal values will only be 1 or 2 hex digits long...

=RIGHT("0"&DEC2HEX((I28-H28)/40),2)
 
R

Ron Rosenfeld

Cell has the following formula
=DEC2HEX((I28-H28)/40)

The output is a hecidecimal A. I would like it to be 0A. Hex numbers
vary from 00 to FFand I neee help wiith the formatting.

Did you check HELP for the function? That is what the optional [places]
argument is for.

=DEC2HEX((I28-H28)/40,2)

--ron
 
R

Rick Rothstein

He-he... obviously I didn't. <g>

--
Rick (MVP - Excel)


Ron Rosenfeld said:
Cell has the following formula
=DEC2HEX((I28-H28)/40)

The output is a hecidecimal A. I would like it to be 0A. Hex numbers
vary from 00 to FFand I neee help wiith the formatting.

Did you check HELP for the function? That is what the optional [places]
argument is for.

=DEC2HEX((I28-H28)/40,2)

--ron
 
R

Ron Rosenfeld

He-he... obviously I didn't. <g>

Sorry. I had addressed my comment to the OP. It looks as if it is threaded
that way on my news reader (Agent). Maybe it looks different on yours?
--ron
 
R

Rick Rothstein

No apology necessary, you didn't do anything wrong. I know you addressed
your comment to the OP... my comment wasn't responding to your statement as
if you had addressed it to me... I was just noting that obviously I didn't
look up the function in the help files either (obvious from the fact that I
posted a more involved "RIGHT function with concatenation" solution that
didn't use the available optional argument... I thought that was kind of
funny. I don't have any occasion to use Hex/Decimal conversions, so I just
went with what the OP posted (assuming there was no built-in way of
specifying digits because he didn't use any) and posted my solution without
looking the function up for myself. I'm glad you came along and showed the
OP the correct way to solve his problem.
 
R

Ron Rosenfeld

No apology necessary, you didn't do anything wrong. I know you addressed
your comment to the OP... my comment wasn't responding to your statement as
if you had addressed it to me... I was just noting that obviously I didn't
look up the function in the help files either (obvious from the fact that I
posted a more involved "RIGHT function with concatenation" solution that
didn't use the available optional argument... I thought that was kind of
funny. I don't have any occasion to use Hex/Decimal conversions, so I just
went with what the OP posted (assuming there was no built-in way of
specifying digits because he didn't use any) and posted my solution without
looking the function up for myself. I'm glad you came along and showed the
OP the correct way to solve his problem.

Ah. Now I see. When I posted my comment, I had not seen yours. And even
after, I didn't look at yours more closely. I just glanced at it and, seeing
the ...,2), I just quickly jumped to the conclusion that the "2" was the
optional argument for the dec2hex function, and completely missed that it was
the numchars argument for the right function.

Just goes to show how my bias affected what I saw.
--ron
 

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