ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Formatting formula output (https://www.excelbanter.com/excel-programming/423630-formatting-formula-output.html)

Fan924

Formatting formula output
 
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.

Rick Rothstein

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

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

--
Rick (MVP - Excel)


"Fan924" wrote in message
...
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.



Ron Rosenfeld

Formatting formula output
 
On Sat, 7 Feb 2009 17:16:12 -0800 (PST), Fan924 wrote:

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

Rick Rothstein

Formatting formula output
 
He-he... obviously I didn't. <g

--
Rick (MVP - Excel)


"Ron Rosenfeld" wrote in message
...
On Sat, 7 Feb 2009 17:16:12 -0800 (PST), Fan924 wrote:

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



Ron Rosenfeld

Formatting formula output
 
On Sun, 8 Feb 2009 09:53:08 -0500, "Rick Rothstein"
wrote:

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

Rick Rothstein

Formatting formula output
 
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.

--
Rick (MVP - Excel)


"Ron Rosenfeld" wrote in message
...
On Sun, 8 Feb 2009 09:53:08 -0500, "Rick Rothstein"
wrote:

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



Ron Rosenfeld

Formatting formula output
 
On Sun, 8 Feb 2009 12:21:00 -0500, "Rick Rothstein"
wrote:

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.

--
Rick (MVP - Excel)


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


All times are GMT +1. The time now is 05:38 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com