![]() |
|
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Join Date: Sep 2008
Posts: 289
|
This should be easy for anyone who has ever used hex numbers.
So, I use Hex$(334) and get as a result 14E. How do I convert that 14E to 334? I tried to look for function "dec$", but clearly it's something else. What? |
|
|
|
|
|
#2 |
|
Join Date: May 2007
Location: Brisbane, Australia
Posts: 1,034
|
HEX2DEC
Show All Hide All Converts a hexadecimal number to decimal. If this function is not available, and returns the #NAME? error, install and load the Analysis ToolPak add-in. How? On the Tools menu, click Add-Ins. In the Add-Ins available list, select the Analysis ToolPak box, and then click OK. If necessary, follow the instructions in the setup program. Syntax HEX2DEC(number) Number is the hexadecimal number you want to convert. Number cannot contain more than 10 characters (40 bits). The most significant bit of number is the sign bit. The remaining 39 bits are magnitude bits. Negative numbers are represented using two's-complement notation. Remark If number is not a valid hexadecimal number, HEX2DEC returns the #NUM! error value. Example The example may be easier to understand if you copy it to a blank worksheet. How to copy an example Create a blank workbook or worksheet. Select the example in the Help topic. Note Do not select the row or column headers. Selecting an example from Help Press CTRL+C. In the worksheet, select cell A1, and press CTRL+V. To switch between viewing the results and viewing the formulas that return the results, press CTRL+` (grave accent), or on the Tools menu, point to Formula Auditing, and then click Formula Auditing Mode. 1 2 3 4 A B Formula Description (Result) =HEX2DEC("A5") Converts hexadecimal A5 to decimal (165) =HEX2DEC("FFFFFFFF5B") Converts hexadecimal FFFFFFFF5B to decimal (-165) =HEX2DEC("3DA408B9") Converts hexadecimal 3DA408B9 to decimal (1034160313)
__________________
One of the reasons I love Excel so much is every time I think I have it figured out someone shows me a better/more efficient/ cleaner or faster method to do what I have been doing the long way for years.... http://www.rentacoder.com/RentACoder...RL=AId_7206185 |
|
|
|
|
|
#3 |
|
Join Date: May 2007
Location: Brisbane, Australia
Posts: 1,034
|
Oops sorry - I missed the part where you said VBA
&H10 will return 16 (Simply prefix with &)
__________________
One of the reasons I love Excel so much is every time I think I have it figured out someone shows me a better/more efficient/ cleaner or faster method to do what I have been doing the long way for years.... http://www.rentacoder.com/RentACoder...RL=AId_7206185 |
|
|
|
|
|
#4 | |
|
Join Date: Sep 2008
Posts: 289
|
Quote:
|
|
|
|
|
|
|
#5 | |
|
Join Date: Sep 2008
Posts: 289
|
Quote:
One option would be, of course, to use a worksheet function, but I thought that there has to be some very simple function, like that Hex$() is. Last edited by Jaymond Flurrie; Mar 24th, 2009 at 07:05 AM. |
|
|
|
|
|
|
#6 |
|
Join Date: May 2007
Location: Brisbane, Australia
Posts: 1,034
|
CLng("&H" & Range("A1").Value)
__________________
One of the reasons I love Excel so much is every time I think I have it figured out someone shows me a better/more efficient/ cleaner or faster method to do what I have been doing the long way for years.... http://www.rentacoder.com/RentACoder...RL=AId_7206185 |
|
|
|
|
|
#7 |
|
Join Date: Sep 2008
Posts: 289
|
|
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|