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


A
B
C

DECIMAL
8 DIGITS
6 DIGITS

<tbody>
</tbody>
256691416400144947 99000074 23633

<tbody>
</tbody>

<tbody>
</tbody>
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 change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
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,215,222
Messages
6,123,716
Members
449,116
Latest member
Aaagu

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