4

I need to be able to convert 047C1BEA3A2480 into Decimal. This should convert to 1262359242482816. I have a large amount of hex numbers that need converting so would need a formula or VB script.

I have tried some things including a VB Module, however with this I need to prefix the number with 0X but then gives me a decimal number that is out by 4.

Any ideas would be great.

Community
  • 1
  • 1
Leigh
  • 133
  • 1
  • 10

2 Answers2

3

Use the inbuilt CDec function

Debug.Print CDec("&H" & "047C1BEA3A2480")

This will give you 1262359242482816

Screenshot

enter image description here

Siddharth Rout
  • 147,039
  • 17
  • 206
  • 250
1

Split into 2 7-digits and use the HEX2DEC function. Unfortunately, Excel cannot handle that big a number, so it is rounding when you put it back in Excel. For exmaple, try to paste the decimal version into Excel. But if you want the formula anyway.

=HEX2DEC(LEFT(A4,7))*16^7+HEX2DEC(RIGHT(A4,7))

Otherwise, use Siddarth's solution and put it in Excel as Text.

Robert Co
  • 1,715
  • 8
  • 14