How to format a Microsoft Excel 2007 cell in hexadecimal?
I would like a format a cell in Microsoft Excel 2007 in hexadecimal but am not finding how to do this.
Is there a built-in way to change the base from 10 to 16 for a cell?
microsoft-excel-2007 hexadecimal cell-format
add a comment |
I would like a format a cell in Microsoft Excel 2007 in hexadecimal but am not finding how to do this.
Is there a built-in way to change the base from 10 to 16 for a cell?
microsoft-excel-2007 hexadecimal cell-format
add a comment |
I would like a format a cell in Microsoft Excel 2007 in hexadecimal but am not finding how to do this.
Is there a built-in way to change the base from 10 to 16 for a cell?
microsoft-excel-2007 hexadecimal cell-format
I would like a format a cell in Microsoft Excel 2007 in hexadecimal but am not finding how to do this.
Is there a built-in way to change the base from 10 to 16 for a cell?
microsoft-excel-2007 hexadecimal cell-format
microsoft-excel-2007 hexadecimal cell-format
edited Jun 11 '17 at 22:25
Raystafarian
19.5k105089
19.5k105089
asked Sep 26 '12 at 17:14
WilliamKFWilliamKF
3,9213287129
3,9213287129
add a comment |
add a comment |
6 Answers
6
active
oldest
votes
As mentioned earlier, the formula =DEC2HEX(A1) converts to hex, and DEC2HEX(A1,8) converts to hex with 0 prefix to denote 32 bits. While adding the leading 0's makes the numbers more readable, especially if you use a fixed point font, the hex and decimal versions can get mixed up when all of the digits in the number happen to be 0-9 (e.g. 327701=50015).
An improvement is to add the "0x" prefix. There are 2 ways to do this. ="0x"&DEC2HEX(A1,8) will do the trick, but it changes the field to a text field, so it can no longer easily be used in formulas. Another method is to use a custom format. If you apply the custom format "0x"@ to the cell, then the value of the cell can still be used in an equation. Examples:
╔═══╦════════════════╦════════════╦═════════════════════════════╦═══════════════╗
║ ║ A ║ B ║ ║ ║
╠═══╬════════════════╬════════════╬═════════════════════════════╬═══════════════╣
║ 1 ║ ║ Value ║ Corresponding Formula ║ Number Format ║
║ 2 ║ Decimal ║ 11162790 ║ 11162790 ║ General ║
║ 3 ║ Hex ║ AA54A6 ║ =DEC2HEX(B2) ║ General ║
║ 4 ║ leading 0's ║ 00AA54A6 ║ =DEC2HEX(B2,8) ║ General ║
║ 5 ║ Text 0x prefix ║ 0x00AA54A6 ║ =DEC2HEX(B2,8) ║ "0x"@ ║
║ 6 ║ Text 0x prefix ║ 0x00AA54A6 ║ ="0x" & DEC2HEX(B2,8) ║ General ║
║ 7 ║ Use B5 ║ AA54A600 ║ =DEC2HEX(HEX2DEC(B5) * 256) ║ General ║
║ 8 ║ Use B5 ║ 0xAA54A600 ║ =DEC2HEX(HEX2DEC(B5) * 256) ║ "0x"@ ║
║ 9 ║ Try to use B6 ║ #NUM! ║ =DEC2HEX(HEX2DEC(B6) * 256) ║ General ║
╚═══╩════════════════╩════════════╩═════════════════════════════╩═══════════════╝
However, large numbers with varying digits can still be hard to read, so I like to put commas into decimal numbers and "_"s into hex numbers. First you need to get the upper and lower 16 bits of the number. The upper 16 bits of a 32-bit number can be retrieved with = INT( A1 / 2^16 ). Dividing by 2^16 acts like a right shift of 16 bits, and the INT removes the fractional remainder. MOD can be used to get the lower 16 bits of any 32 or 64-bit number; =MOD(A1, 2^16). The MOD effectively gets the remainder back, which is the lower 16 bits. Here is a table that shows this in action.
╔═══╦═════════════╦═══════════════╦════════════════════════════════════╦═════════╗
║ ║ A ║ B ║ ║ ║
╠═══╬═════════════╬═══════════════╬════════════════════════════════════╬═════════╣
║ 1 ║ ║ Value ║ Corresponding Formula ║ Format ║
║ 2 ║ Decimal ║ 3,098,743,209 ║ 3098743209 ║ #,##0 ║
║ 3 ║ Upper Bytes ║ B8B3 ║ =DEC2HEX(INT( B2/2^16 ), 4) ║ General ║
║ 4 ║ Lower Bytes ║ 11A9 ║ =DEC2HEX(MOD( B2, 2^16 )) ║ General ║
║ 5 ║ Full Number ║ 0xB8B3_11A9 ║ ="0x" & DEC2HEX(INT( B2/2^16 ), 4) ║ General ║
║ ║ ║ ║ & "_" & DEC2HEX(MOD(B2, 2^16), 4) ║ ║
╚═══╩═════════════╩═══════════════╩════════════════════════════════════╩═════════╝
BTW, I have to give a big thanks to https://ozh.github.io/ascii-tables/. I used that link to create the ASCII text tables. I just copied the table from my excel spreadsheet into its Input section and it automatically created the nice unicode text layout.
add a comment |
If you want to format a cell so that you can type in a decimal number and automatically have it displayed as a hexadecimal number, then that's not possible. You can either format the cell as text and enter hexadecimal numbers directly (but note that Excel cannot use those for calculations), or use the DEC2HEX()
and HEX2DEC()
functions to convert between base 10 and base 16.
1
For reference, there is alsoDEC2BIN()
which converts to binary. For fixed width binary, use something like=TEXT(DEC2BIN(A1), "0000")
– Tor Klingberg
Jul 28 '15 at 14:11
1
On a German localized Excel 2013, DEC2HEX and HEX2DEC result in the error message #NAME?. With the Office Help, I could find out that the functions are called DEZINHEX and HEXINDEZ, resp.
– Bernhard Hiller
Jul 18 '16 at 9:41
How do I extend =0x1234AB to =0x001234AB (I need fixed width of 8)?
– Danijel
Jan 27 '17 at 8:59
@Danijel Use the second parameter of DEC2HEX.
– Vincent G
Feb 1 '17 at 8:46
add a comment |
If cell to be converted is A1
use =DEC2HEX(A1)
.
2
You may want to add a leading "0x" to your hex value. Use="0x"&DEC2HEX(A1,4)
to get a result that looks like like0x1AF2
.
– User5910
Jun 30 '16 at 22:47
add a comment |
If you need to perform mathematical operations on numbers converted to hex, first convert them to decimal, perform the operation, then convert back to hex.
For example, if cell A1
has a hex number, such as would be created from this formula:
=DEC2HEX(17)
which would be displayed as 11, and cell A2
has formula:
=DEC2HEX(165)
which would be displayed as A5
, and you want to add them together, then this formula would get the desired result:
=DEC2HEX(HEX2DEC(A1)+HEX2DEC(A2))
which would be displayed as B6
add a comment |
=REPT("0",4-LEN(DEC2HEX(B3)))&DEC2HEX(B3)
The REPT formula repeats the "0" based on the length of the hex string that is generated by converting it from a decimal, and the desired length of the HEX string. In this example I am looking to generate HEX strings of length 4.
You then concatenate the leading zeros to the actual HEX string, thereby generating the HEX value of the desired length.
Advantages:
- Easy coping of the formula to other worksheet. With only two cell references to a decimal value, B3, to reassign.
- The results of this formula are treated as HEX values by Excel. You could also prefix the "0x", but I do not find it necessary.
Note: I use this when I am copying HEX strings and they get copied over at varying lengths. I first generate a column of decimal values from the original values that I can then run this formula against.
add a comment |
Here is a solution I found to make sure I can format these hex numbers into HTML format:
SWITCH(LEN(DEC2HEX(B6)),1,"000"&DEC2HEX(B6),2,"00"&DEC2HEX(B6),3,"0"&DEC2HEX(B6),4,DEC2HEX(B6))
2
An explanation of what is going on in your code would make the answer more useful.
– WilliamKF
Jan 20 '17 at 21:52
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f479948%2fhow-to-format-a-microsoft-excel-2007-cell-in-hexadecimal%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
6 Answers
6
active
oldest
votes
6 Answers
6
active
oldest
votes
active
oldest
votes
active
oldest
votes
As mentioned earlier, the formula =DEC2HEX(A1) converts to hex, and DEC2HEX(A1,8) converts to hex with 0 prefix to denote 32 bits. While adding the leading 0's makes the numbers more readable, especially if you use a fixed point font, the hex and decimal versions can get mixed up when all of the digits in the number happen to be 0-9 (e.g. 327701=50015).
An improvement is to add the "0x" prefix. There are 2 ways to do this. ="0x"&DEC2HEX(A1,8) will do the trick, but it changes the field to a text field, so it can no longer easily be used in formulas. Another method is to use a custom format. If you apply the custom format "0x"@ to the cell, then the value of the cell can still be used in an equation. Examples:
╔═══╦════════════════╦════════════╦═════════════════════════════╦═══════════════╗
║ ║ A ║ B ║ ║ ║
╠═══╬════════════════╬════════════╬═════════════════════════════╬═══════════════╣
║ 1 ║ ║ Value ║ Corresponding Formula ║ Number Format ║
║ 2 ║ Decimal ║ 11162790 ║ 11162790 ║ General ║
║ 3 ║ Hex ║ AA54A6 ║ =DEC2HEX(B2) ║ General ║
║ 4 ║ leading 0's ║ 00AA54A6 ║ =DEC2HEX(B2,8) ║ General ║
║ 5 ║ Text 0x prefix ║ 0x00AA54A6 ║ =DEC2HEX(B2,8) ║ "0x"@ ║
║ 6 ║ Text 0x prefix ║ 0x00AA54A6 ║ ="0x" & DEC2HEX(B2,8) ║ General ║
║ 7 ║ Use B5 ║ AA54A600 ║ =DEC2HEX(HEX2DEC(B5) * 256) ║ General ║
║ 8 ║ Use B5 ║ 0xAA54A600 ║ =DEC2HEX(HEX2DEC(B5) * 256) ║ "0x"@ ║
║ 9 ║ Try to use B6 ║ #NUM! ║ =DEC2HEX(HEX2DEC(B6) * 256) ║ General ║
╚═══╩════════════════╩════════════╩═════════════════════════════╩═══════════════╝
However, large numbers with varying digits can still be hard to read, so I like to put commas into decimal numbers and "_"s into hex numbers. First you need to get the upper and lower 16 bits of the number. The upper 16 bits of a 32-bit number can be retrieved with = INT( A1 / 2^16 ). Dividing by 2^16 acts like a right shift of 16 bits, and the INT removes the fractional remainder. MOD can be used to get the lower 16 bits of any 32 or 64-bit number; =MOD(A1, 2^16). The MOD effectively gets the remainder back, which is the lower 16 bits. Here is a table that shows this in action.
╔═══╦═════════════╦═══════════════╦════════════════════════════════════╦═════════╗
║ ║ A ║ B ║ ║ ║
╠═══╬═════════════╬═══════════════╬════════════════════════════════════╬═════════╣
║ 1 ║ ║ Value ║ Corresponding Formula ║ Format ║
║ 2 ║ Decimal ║ 3,098,743,209 ║ 3098743209 ║ #,##0 ║
║ 3 ║ Upper Bytes ║ B8B3 ║ =DEC2HEX(INT( B2/2^16 ), 4) ║ General ║
║ 4 ║ Lower Bytes ║ 11A9 ║ =DEC2HEX(MOD( B2, 2^16 )) ║ General ║
║ 5 ║ Full Number ║ 0xB8B3_11A9 ║ ="0x" & DEC2HEX(INT( B2/2^16 ), 4) ║ General ║
║ ║ ║ ║ & "_" & DEC2HEX(MOD(B2, 2^16), 4) ║ ║
╚═══╩═════════════╩═══════════════╩════════════════════════════════════╩═════════╝
BTW, I have to give a big thanks to https://ozh.github.io/ascii-tables/. I used that link to create the ASCII text tables. I just copied the table from my excel spreadsheet into its Input section and it automatically created the nice unicode text layout.
add a comment |
As mentioned earlier, the formula =DEC2HEX(A1) converts to hex, and DEC2HEX(A1,8) converts to hex with 0 prefix to denote 32 bits. While adding the leading 0's makes the numbers more readable, especially if you use a fixed point font, the hex and decimal versions can get mixed up when all of the digits in the number happen to be 0-9 (e.g. 327701=50015).
An improvement is to add the "0x" prefix. There are 2 ways to do this. ="0x"&DEC2HEX(A1,8) will do the trick, but it changes the field to a text field, so it can no longer easily be used in formulas. Another method is to use a custom format. If you apply the custom format "0x"@ to the cell, then the value of the cell can still be used in an equation. Examples:
╔═══╦════════════════╦════════════╦═════════════════════════════╦═══════════════╗
║ ║ A ║ B ║ ║ ║
╠═══╬════════════════╬════════════╬═════════════════════════════╬═══════════════╣
║ 1 ║ ║ Value ║ Corresponding Formula ║ Number Format ║
║ 2 ║ Decimal ║ 11162790 ║ 11162790 ║ General ║
║ 3 ║ Hex ║ AA54A6 ║ =DEC2HEX(B2) ║ General ║
║ 4 ║ leading 0's ║ 00AA54A6 ║ =DEC2HEX(B2,8) ║ General ║
║ 5 ║ Text 0x prefix ║ 0x00AA54A6 ║ =DEC2HEX(B2,8) ║ "0x"@ ║
║ 6 ║ Text 0x prefix ║ 0x00AA54A6 ║ ="0x" & DEC2HEX(B2,8) ║ General ║
║ 7 ║ Use B5 ║ AA54A600 ║ =DEC2HEX(HEX2DEC(B5) * 256) ║ General ║
║ 8 ║ Use B5 ║ 0xAA54A600 ║ =DEC2HEX(HEX2DEC(B5) * 256) ║ "0x"@ ║
║ 9 ║ Try to use B6 ║ #NUM! ║ =DEC2HEX(HEX2DEC(B6) * 256) ║ General ║
╚═══╩════════════════╩════════════╩═════════════════════════════╩═══════════════╝
However, large numbers with varying digits can still be hard to read, so I like to put commas into decimal numbers and "_"s into hex numbers. First you need to get the upper and lower 16 bits of the number. The upper 16 bits of a 32-bit number can be retrieved with = INT( A1 / 2^16 ). Dividing by 2^16 acts like a right shift of 16 bits, and the INT removes the fractional remainder. MOD can be used to get the lower 16 bits of any 32 or 64-bit number; =MOD(A1, 2^16). The MOD effectively gets the remainder back, which is the lower 16 bits. Here is a table that shows this in action.
╔═══╦═════════════╦═══════════════╦════════════════════════════════════╦═════════╗
║ ║ A ║ B ║ ║ ║
╠═══╬═════════════╬═══════════════╬════════════════════════════════════╬═════════╣
║ 1 ║ ║ Value ║ Corresponding Formula ║ Format ║
║ 2 ║ Decimal ║ 3,098,743,209 ║ 3098743209 ║ #,##0 ║
║ 3 ║ Upper Bytes ║ B8B3 ║ =DEC2HEX(INT( B2/2^16 ), 4) ║ General ║
║ 4 ║ Lower Bytes ║ 11A9 ║ =DEC2HEX(MOD( B2, 2^16 )) ║ General ║
║ 5 ║ Full Number ║ 0xB8B3_11A9 ║ ="0x" & DEC2HEX(INT( B2/2^16 ), 4) ║ General ║
║ ║ ║ ║ & "_" & DEC2HEX(MOD(B2, 2^16), 4) ║ ║
╚═══╩═════════════╩═══════════════╩════════════════════════════════════╩═════════╝
BTW, I have to give a big thanks to https://ozh.github.io/ascii-tables/. I used that link to create the ASCII text tables. I just copied the table from my excel spreadsheet into its Input section and it automatically created the nice unicode text layout.
add a comment |
As mentioned earlier, the formula =DEC2HEX(A1) converts to hex, and DEC2HEX(A1,8) converts to hex with 0 prefix to denote 32 bits. While adding the leading 0's makes the numbers more readable, especially if you use a fixed point font, the hex and decimal versions can get mixed up when all of the digits in the number happen to be 0-9 (e.g. 327701=50015).
An improvement is to add the "0x" prefix. There are 2 ways to do this. ="0x"&DEC2HEX(A1,8) will do the trick, but it changes the field to a text field, so it can no longer easily be used in formulas. Another method is to use a custom format. If you apply the custom format "0x"@ to the cell, then the value of the cell can still be used in an equation. Examples:
╔═══╦════════════════╦════════════╦═════════════════════════════╦═══════════════╗
║ ║ A ║ B ║ ║ ║
╠═══╬════════════════╬════════════╬═════════════════════════════╬═══════════════╣
║ 1 ║ ║ Value ║ Corresponding Formula ║ Number Format ║
║ 2 ║ Decimal ║ 11162790 ║ 11162790 ║ General ║
║ 3 ║ Hex ║ AA54A6 ║ =DEC2HEX(B2) ║ General ║
║ 4 ║ leading 0's ║ 00AA54A6 ║ =DEC2HEX(B2,8) ║ General ║
║ 5 ║ Text 0x prefix ║ 0x00AA54A6 ║ =DEC2HEX(B2,8) ║ "0x"@ ║
║ 6 ║ Text 0x prefix ║ 0x00AA54A6 ║ ="0x" & DEC2HEX(B2,8) ║ General ║
║ 7 ║ Use B5 ║ AA54A600 ║ =DEC2HEX(HEX2DEC(B5) * 256) ║ General ║
║ 8 ║ Use B5 ║ 0xAA54A600 ║ =DEC2HEX(HEX2DEC(B5) * 256) ║ "0x"@ ║
║ 9 ║ Try to use B6 ║ #NUM! ║ =DEC2HEX(HEX2DEC(B6) * 256) ║ General ║
╚═══╩════════════════╩════════════╩═════════════════════════════╩═══════════════╝
However, large numbers with varying digits can still be hard to read, so I like to put commas into decimal numbers and "_"s into hex numbers. First you need to get the upper and lower 16 bits of the number. The upper 16 bits of a 32-bit number can be retrieved with = INT( A1 / 2^16 ). Dividing by 2^16 acts like a right shift of 16 bits, and the INT removes the fractional remainder. MOD can be used to get the lower 16 bits of any 32 or 64-bit number; =MOD(A1, 2^16). The MOD effectively gets the remainder back, which is the lower 16 bits. Here is a table that shows this in action.
╔═══╦═════════════╦═══════════════╦════════════════════════════════════╦═════════╗
║ ║ A ║ B ║ ║ ║
╠═══╬═════════════╬═══════════════╬════════════════════════════════════╬═════════╣
║ 1 ║ ║ Value ║ Corresponding Formula ║ Format ║
║ 2 ║ Decimal ║ 3,098,743,209 ║ 3098743209 ║ #,##0 ║
║ 3 ║ Upper Bytes ║ B8B3 ║ =DEC2HEX(INT( B2/2^16 ), 4) ║ General ║
║ 4 ║ Lower Bytes ║ 11A9 ║ =DEC2HEX(MOD( B2, 2^16 )) ║ General ║
║ 5 ║ Full Number ║ 0xB8B3_11A9 ║ ="0x" & DEC2HEX(INT( B2/2^16 ), 4) ║ General ║
║ ║ ║ ║ & "_" & DEC2HEX(MOD(B2, 2^16), 4) ║ ║
╚═══╩═════════════╩═══════════════╩════════════════════════════════════╩═════════╝
BTW, I have to give a big thanks to https://ozh.github.io/ascii-tables/. I used that link to create the ASCII text tables. I just copied the table from my excel spreadsheet into its Input section and it automatically created the nice unicode text layout.
As mentioned earlier, the formula =DEC2HEX(A1) converts to hex, and DEC2HEX(A1,8) converts to hex with 0 prefix to denote 32 bits. While adding the leading 0's makes the numbers more readable, especially if you use a fixed point font, the hex and decimal versions can get mixed up when all of the digits in the number happen to be 0-9 (e.g. 327701=50015).
An improvement is to add the "0x" prefix. There are 2 ways to do this. ="0x"&DEC2HEX(A1,8) will do the trick, but it changes the field to a text field, so it can no longer easily be used in formulas. Another method is to use a custom format. If you apply the custom format "0x"@ to the cell, then the value of the cell can still be used in an equation. Examples:
╔═══╦════════════════╦════════════╦═════════════════════════════╦═══════════════╗
║ ║ A ║ B ║ ║ ║
╠═══╬════════════════╬════════════╬═════════════════════════════╬═══════════════╣
║ 1 ║ ║ Value ║ Corresponding Formula ║ Number Format ║
║ 2 ║ Decimal ║ 11162790 ║ 11162790 ║ General ║
║ 3 ║ Hex ║ AA54A6 ║ =DEC2HEX(B2) ║ General ║
║ 4 ║ leading 0's ║ 00AA54A6 ║ =DEC2HEX(B2,8) ║ General ║
║ 5 ║ Text 0x prefix ║ 0x00AA54A6 ║ =DEC2HEX(B2,8) ║ "0x"@ ║
║ 6 ║ Text 0x prefix ║ 0x00AA54A6 ║ ="0x" & DEC2HEX(B2,8) ║ General ║
║ 7 ║ Use B5 ║ AA54A600 ║ =DEC2HEX(HEX2DEC(B5) * 256) ║ General ║
║ 8 ║ Use B5 ║ 0xAA54A600 ║ =DEC2HEX(HEX2DEC(B5) * 256) ║ "0x"@ ║
║ 9 ║ Try to use B6 ║ #NUM! ║ =DEC2HEX(HEX2DEC(B6) * 256) ║ General ║
╚═══╩════════════════╩════════════╩═════════════════════════════╩═══════════════╝
However, large numbers with varying digits can still be hard to read, so I like to put commas into decimal numbers and "_"s into hex numbers. First you need to get the upper and lower 16 bits of the number. The upper 16 bits of a 32-bit number can be retrieved with = INT( A1 / 2^16 ). Dividing by 2^16 acts like a right shift of 16 bits, and the INT removes the fractional remainder. MOD can be used to get the lower 16 bits of any 32 or 64-bit number; =MOD(A1, 2^16). The MOD effectively gets the remainder back, which is the lower 16 bits. Here is a table that shows this in action.
╔═══╦═════════════╦═══════════════╦════════════════════════════════════╦═════════╗
║ ║ A ║ B ║ ║ ║
╠═══╬═════════════╬═══════════════╬════════════════════════════════════╬═════════╣
║ 1 ║ ║ Value ║ Corresponding Formula ║ Format ║
║ 2 ║ Decimal ║ 3,098,743,209 ║ 3098743209 ║ #,##0 ║
║ 3 ║ Upper Bytes ║ B8B3 ║ =DEC2HEX(INT( B2/2^16 ), 4) ║ General ║
║ 4 ║ Lower Bytes ║ 11A9 ║ =DEC2HEX(MOD( B2, 2^16 )) ║ General ║
║ 5 ║ Full Number ║ 0xB8B3_11A9 ║ ="0x" & DEC2HEX(INT( B2/2^16 ), 4) ║ General ║
║ ║ ║ ║ & "_" & DEC2HEX(MOD(B2, 2^16), 4) ║ ║
╚═══╩═════════════╩═══════════════╩════════════════════════════════════╩═════════╝
BTW, I have to give a big thanks to https://ozh.github.io/ascii-tables/. I used that link to create the ASCII text tables. I just copied the table from my excel spreadsheet into its Input section and it automatically created the nice unicode text layout.
answered Apr 20 '17 at 1:48
OldEmbeddedGuyOldEmbeddedGuy
16613
16613
add a comment |
add a comment |
If you want to format a cell so that you can type in a decimal number and automatically have it displayed as a hexadecimal number, then that's not possible. You can either format the cell as text and enter hexadecimal numbers directly (but note that Excel cannot use those for calculations), or use the DEC2HEX()
and HEX2DEC()
functions to convert between base 10 and base 16.
1
For reference, there is alsoDEC2BIN()
which converts to binary. For fixed width binary, use something like=TEXT(DEC2BIN(A1), "0000")
– Tor Klingberg
Jul 28 '15 at 14:11
1
On a German localized Excel 2013, DEC2HEX and HEX2DEC result in the error message #NAME?. With the Office Help, I could find out that the functions are called DEZINHEX and HEXINDEZ, resp.
– Bernhard Hiller
Jul 18 '16 at 9:41
How do I extend =0x1234AB to =0x001234AB (I need fixed width of 8)?
– Danijel
Jan 27 '17 at 8:59
@Danijel Use the second parameter of DEC2HEX.
– Vincent G
Feb 1 '17 at 8:46
add a comment |
If you want to format a cell so that you can type in a decimal number and automatically have it displayed as a hexadecimal number, then that's not possible. You can either format the cell as text and enter hexadecimal numbers directly (but note that Excel cannot use those for calculations), or use the DEC2HEX()
and HEX2DEC()
functions to convert between base 10 and base 16.
1
For reference, there is alsoDEC2BIN()
which converts to binary. For fixed width binary, use something like=TEXT(DEC2BIN(A1), "0000")
– Tor Klingberg
Jul 28 '15 at 14:11
1
On a German localized Excel 2013, DEC2HEX and HEX2DEC result in the error message #NAME?. With the Office Help, I could find out that the functions are called DEZINHEX and HEXINDEZ, resp.
– Bernhard Hiller
Jul 18 '16 at 9:41
How do I extend =0x1234AB to =0x001234AB (I need fixed width of 8)?
– Danijel
Jan 27 '17 at 8:59
@Danijel Use the second parameter of DEC2HEX.
– Vincent G
Feb 1 '17 at 8:46
add a comment |
If you want to format a cell so that you can type in a decimal number and automatically have it displayed as a hexadecimal number, then that's not possible. You can either format the cell as text and enter hexadecimal numbers directly (but note that Excel cannot use those for calculations), or use the DEC2HEX()
and HEX2DEC()
functions to convert between base 10 and base 16.
If you want to format a cell so that you can type in a decimal number and automatically have it displayed as a hexadecimal number, then that's not possible. You can either format the cell as text and enter hexadecimal numbers directly (but note that Excel cannot use those for calculations), or use the DEC2HEX()
and HEX2DEC()
functions to convert between base 10 and base 16.
answered Sep 26 '12 at 17:24
IndrekIndrek
20.6k117484
20.6k117484
1
For reference, there is alsoDEC2BIN()
which converts to binary. For fixed width binary, use something like=TEXT(DEC2BIN(A1), "0000")
– Tor Klingberg
Jul 28 '15 at 14:11
1
On a German localized Excel 2013, DEC2HEX and HEX2DEC result in the error message #NAME?. With the Office Help, I could find out that the functions are called DEZINHEX and HEXINDEZ, resp.
– Bernhard Hiller
Jul 18 '16 at 9:41
How do I extend =0x1234AB to =0x001234AB (I need fixed width of 8)?
– Danijel
Jan 27 '17 at 8:59
@Danijel Use the second parameter of DEC2HEX.
– Vincent G
Feb 1 '17 at 8:46
add a comment |
1
For reference, there is alsoDEC2BIN()
which converts to binary. For fixed width binary, use something like=TEXT(DEC2BIN(A1), "0000")
– Tor Klingberg
Jul 28 '15 at 14:11
1
On a German localized Excel 2013, DEC2HEX and HEX2DEC result in the error message #NAME?. With the Office Help, I could find out that the functions are called DEZINHEX and HEXINDEZ, resp.
– Bernhard Hiller
Jul 18 '16 at 9:41
How do I extend =0x1234AB to =0x001234AB (I need fixed width of 8)?
– Danijel
Jan 27 '17 at 8:59
@Danijel Use the second parameter of DEC2HEX.
– Vincent G
Feb 1 '17 at 8:46
1
1
For reference, there is also
DEC2BIN()
which converts to binary. For fixed width binary, use something like =TEXT(DEC2BIN(A1), "0000")
– Tor Klingberg
Jul 28 '15 at 14:11
For reference, there is also
DEC2BIN()
which converts to binary. For fixed width binary, use something like =TEXT(DEC2BIN(A1), "0000")
– Tor Klingberg
Jul 28 '15 at 14:11
1
1
On a German localized Excel 2013, DEC2HEX and HEX2DEC result in the error message #NAME?. With the Office Help, I could find out that the functions are called DEZINHEX and HEXINDEZ, resp.
– Bernhard Hiller
Jul 18 '16 at 9:41
On a German localized Excel 2013, DEC2HEX and HEX2DEC result in the error message #NAME?. With the Office Help, I could find out that the functions are called DEZINHEX and HEXINDEZ, resp.
– Bernhard Hiller
Jul 18 '16 at 9:41
How do I extend =0x1234AB to =0x001234AB (I need fixed width of 8)?
– Danijel
Jan 27 '17 at 8:59
How do I extend =0x1234AB to =0x001234AB (I need fixed width of 8)?
– Danijel
Jan 27 '17 at 8:59
@Danijel Use the second parameter of DEC2HEX.
– Vincent G
Feb 1 '17 at 8:46
@Danijel Use the second parameter of DEC2HEX.
– Vincent G
Feb 1 '17 at 8:46
add a comment |
If cell to be converted is A1
use =DEC2HEX(A1)
.
2
You may want to add a leading "0x" to your hex value. Use="0x"&DEC2HEX(A1,4)
to get a result that looks like like0x1AF2
.
– User5910
Jun 30 '16 at 22:47
add a comment |
If cell to be converted is A1
use =DEC2HEX(A1)
.
2
You may want to add a leading "0x" to your hex value. Use="0x"&DEC2HEX(A1,4)
to get a result that looks like like0x1AF2
.
– User5910
Jun 30 '16 at 22:47
add a comment |
If cell to be converted is A1
use =DEC2HEX(A1)
.
If cell to be converted is A1
use =DEC2HEX(A1)
.
answered Sep 26 '12 at 17:20
pnutspnuts
5,55032239
5,55032239
2
You may want to add a leading "0x" to your hex value. Use="0x"&DEC2HEX(A1,4)
to get a result that looks like like0x1AF2
.
– User5910
Jun 30 '16 at 22:47
add a comment |
2
You may want to add a leading "0x" to your hex value. Use="0x"&DEC2HEX(A1,4)
to get a result that looks like like0x1AF2
.
– User5910
Jun 30 '16 at 22:47
2
2
You may want to add a leading "0x" to your hex value. Use
="0x"&DEC2HEX(A1,4)
to get a result that looks like like 0x1AF2
.– User5910
Jun 30 '16 at 22:47
You may want to add a leading "0x" to your hex value. Use
="0x"&DEC2HEX(A1,4)
to get a result that looks like like 0x1AF2
.– User5910
Jun 30 '16 at 22:47
add a comment |
If you need to perform mathematical operations on numbers converted to hex, first convert them to decimal, perform the operation, then convert back to hex.
For example, if cell A1
has a hex number, such as would be created from this formula:
=DEC2HEX(17)
which would be displayed as 11, and cell A2
has formula:
=DEC2HEX(165)
which would be displayed as A5
, and you want to add them together, then this formula would get the desired result:
=DEC2HEX(HEX2DEC(A1)+HEX2DEC(A2))
which would be displayed as B6
add a comment |
If you need to perform mathematical operations on numbers converted to hex, first convert them to decimal, perform the operation, then convert back to hex.
For example, if cell A1
has a hex number, such as would be created from this formula:
=DEC2HEX(17)
which would be displayed as 11, and cell A2
has formula:
=DEC2HEX(165)
which would be displayed as A5
, and you want to add them together, then this formula would get the desired result:
=DEC2HEX(HEX2DEC(A1)+HEX2DEC(A2))
which would be displayed as B6
add a comment |
If you need to perform mathematical operations on numbers converted to hex, first convert them to decimal, perform the operation, then convert back to hex.
For example, if cell A1
has a hex number, such as would be created from this formula:
=DEC2HEX(17)
which would be displayed as 11, and cell A2
has formula:
=DEC2HEX(165)
which would be displayed as A5
, and you want to add them together, then this formula would get the desired result:
=DEC2HEX(HEX2DEC(A1)+HEX2DEC(A2))
which would be displayed as B6
If you need to perform mathematical operations on numbers converted to hex, first convert them to decimal, perform the operation, then convert back to hex.
For example, if cell A1
has a hex number, such as would be created from this formula:
=DEC2HEX(17)
which would be displayed as 11, and cell A2
has formula:
=DEC2HEX(165)
which would be displayed as A5
, and you want to add them together, then this formula would get the desired result:
=DEC2HEX(HEX2DEC(A1)+HEX2DEC(A2))
which would be displayed as B6
edited Apr 20 '17 at 3:18
Stephen Rauch
2,29581725
2,29581725
answered Dec 31 '13 at 3:16
TestItTestIt
411
411
add a comment |
add a comment |
=REPT("0",4-LEN(DEC2HEX(B3)))&DEC2HEX(B3)
The REPT formula repeats the "0" based on the length of the hex string that is generated by converting it from a decimal, and the desired length of the HEX string. In this example I am looking to generate HEX strings of length 4.
You then concatenate the leading zeros to the actual HEX string, thereby generating the HEX value of the desired length.
Advantages:
- Easy coping of the formula to other worksheet. With only two cell references to a decimal value, B3, to reassign.
- The results of this formula are treated as HEX values by Excel. You could also prefix the "0x", but I do not find it necessary.
Note: I use this when I am copying HEX strings and they get copied over at varying lengths. I first generate a column of decimal values from the original values that I can then run this formula against.
add a comment |
=REPT("0",4-LEN(DEC2HEX(B3)))&DEC2HEX(B3)
The REPT formula repeats the "0" based on the length of the hex string that is generated by converting it from a decimal, and the desired length of the HEX string. In this example I am looking to generate HEX strings of length 4.
You then concatenate the leading zeros to the actual HEX string, thereby generating the HEX value of the desired length.
Advantages:
- Easy coping of the formula to other worksheet. With only two cell references to a decimal value, B3, to reassign.
- The results of this formula are treated as HEX values by Excel. You could also prefix the "0x", but I do not find it necessary.
Note: I use this when I am copying HEX strings and they get copied over at varying lengths. I first generate a column of decimal values from the original values that I can then run this formula against.
add a comment |
=REPT("0",4-LEN(DEC2HEX(B3)))&DEC2HEX(B3)
The REPT formula repeats the "0" based on the length of the hex string that is generated by converting it from a decimal, and the desired length of the HEX string. In this example I am looking to generate HEX strings of length 4.
You then concatenate the leading zeros to the actual HEX string, thereby generating the HEX value of the desired length.
Advantages:
- Easy coping of the formula to other worksheet. With only two cell references to a decimal value, B3, to reassign.
- The results of this formula are treated as HEX values by Excel. You could also prefix the "0x", but I do not find it necessary.
Note: I use this when I am copying HEX strings and they get copied over at varying lengths. I first generate a column of decimal values from the original values that I can then run this formula against.
=REPT("0",4-LEN(DEC2HEX(B3)))&DEC2HEX(B3)
The REPT formula repeats the "0" based on the length of the hex string that is generated by converting it from a decimal, and the desired length of the HEX string. In this example I am looking to generate HEX strings of length 4.
You then concatenate the leading zeros to the actual HEX string, thereby generating the HEX value of the desired length.
Advantages:
- Easy coping of the formula to other worksheet. With only two cell references to a decimal value, B3, to reassign.
- The results of this formula are treated as HEX values by Excel. You could also prefix the "0x", but I do not find it necessary.
Note: I use this when I am copying HEX strings and they get copied over at varying lengths. I first generate a column of decimal values from the original values that I can then run this formula against.
answered Jul 25 '18 at 14:35
WSimpsonWSimpson
1111
1111
add a comment |
add a comment |
Here is a solution I found to make sure I can format these hex numbers into HTML format:
SWITCH(LEN(DEC2HEX(B6)),1,"000"&DEC2HEX(B6),2,"00"&DEC2HEX(B6),3,"0"&DEC2HEX(B6),4,DEC2HEX(B6))
2
An explanation of what is going on in your code would make the answer more useful.
– WilliamKF
Jan 20 '17 at 21:52
add a comment |
Here is a solution I found to make sure I can format these hex numbers into HTML format:
SWITCH(LEN(DEC2HEX(B6)),1,"000"&DEC2HEX(B6),2,"00"&DEC2HEX(B6),3,"0"&DEC2HEX(B6),4,DEC2HEX(B6))
2
An explanation of what is going on in your code would make the answer more useful.
– WilliamKF
Jan 20 '17 at 21:52
add a comment |
Here is a solution I found to make sure I can format these hex numbers into HTML format:
SWITCH(LEN(DEC2HEX(B6)),1,"000"&DEC2HEX(B6),2,"00"&DEC2HEX(B6),3,"0"&DEC2HEX(B6),4,DEC2HEX(B6))
Here is a solution I found to make sure I can format these hex numbers into HTML format:
SWITCH(LEN(DEC2HEX(B6)),1,"000"&DEC2HEX(B6),2,"00"&DEC2HEX(B6),3,"0"&DEC2HEX(B6),4,DEC2HEX(B6))
edited Jan 19 '17 at 20:18
fixer1234
18.8k144982
18.8k144982
answered Jan 19 '17 at 19:55
Stephen FrickStephen Frick
1
1
2
An explanation of what is going on in your code would make the answer more useful.
– WilliamKF
Jan 20 '17 at 21:52
add a comment |
2
An explanation of what is going on in your code would make the answer more useful.
– WilliamKF
Jan 20 '17 at 21:52
2
2
An explanation of what is going on in your code would make the answer more useful.
– WilliamKF
Jan 20 '17 at 21:52
An explanation of what is going on in your code would make the answer more useful.
– WilliamKF
Jan 20 '17 at 21:52
add a comment |
Thanks for contributing an answer to Super User!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f479948%2fhow-to-format-a-microsoft-excel-2007-cell-in-hexadecimal%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown