Conversion from decimal to hex issue.

kcmihrguy

New Member
Joined
Apr 20, 2013
Messages
14
I have an issue, see below, I am working up a spreadsheet to convert decimals to hex and hex to decimal


[TABLE="width: 636"]
<tbody>[TR]
[TD]A
[/TD]
[TD]B
[/TD]
[TD]C
[/TD]
[TD]
[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]DECIMAL
[/TD]
[TD]8 DIGITS
[/TD]
[TD]6 DIGITS
[/TD]
[TD="align: right"][/TD]
[/TR]
</tbody>[/TABLE]
[TABLE="width: 636"]
<tbody>[TR]
[TD][TABLE="width: 313"]
<tbody>[TR]
[TD="class: xl67, width: 161"]256691416400144947 [/TD]
[TD="class: xl66, width: 80"]99000074 [/TD]
[TD="class: xl65, width: 72"] 23633[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
Formula in B2 =DEC2HEX(LEFT(A2,10)*1) Formula in C2=DEC2HEX(RIGHT(A2,8)*1)
Note: 2nd row is column labels-row1
3rd row is data-row2

The issue is in C2, if the answer has a zero at the beginning it drops the zero and I need that(using this particular number in A2)- this will change as serial numbers change so the leading zero isn't always an issue, this will be used for conversion of serial numbers to and from decimal to hex and I need to split into 2 numbers to get what I want. How can I get the leading zero back? Can I?

<tbody>
</tbody>
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
Like this maybe:

Excel Workbook
ABC
225669141640014400099000074023280
Sheet1
 
Upvote 0
I don't think that will work. Dec2Hex will already be a string.

Try this:
=Right("000000" & DEC2HEX(Right(A2,8)*1),6)
 
Upvote 0
There is a 2nd parameter available for DEC2HEX that allows you to specify the number of digits.

=DEC2HEX(Right(A2,8),6)

It will also work without coercing it to a number.
 
Upvote 0
There is a 2nd parameter available for DEC2HEX that allows you to specify the number of digits.

=DEC2HEX(Right(A2,8),6)

It will also work without coercing it to a number.


Thanks Scott. Silly me I assumed they were WRITING the converter. I didn't realize it was a built in function or I'd have seen the second parameter.
 
Upvote 0
SOLVED Re: Conversion from decimal to hex issue.

Thanks Scott. Silly me I assumed they were WRITING the converter. I didn't realize it was a built in function or I'd have seen the second parameter.

Thanks Scott, I also didn't realize that there was a second parameter available.
 
Upvote 0

Forum statistics

Threads
1,223,247
Messages
6,171,007
Members
452,374
Latest member
keccles

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top