Best (faster) way to apply formula to a range

dtrujillano

New Member
Joined
Oct 26, 2012
Messages
1
Hello,

I have a file 1 column and 100.000 rows filled with hexadecimal values that I want to convert to decimal.

I have to use VBA and I need to find something really fast to convert this data.

One idea is to copy the range in an array and access each element with a loop applying hex() function and then return to the sheet.

Other idea is to calculate the decimal value in the next column with Range ("A1:A100000").formular1c1 = "HEX2DEC(RC[-1])" and finally copy values of B1:B100000 to A1:A100000 and clear range B1:B100000.

I think this second method is faster but could it be possible to perform the second idea without making the clear and the copy/paste from column B to column A? (because these operations are wasting time in things that I do not need) Probably it would be even faster if I return directly the results in column A without using column B. I would appreciate any other suggestion.

Thank you
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
Hi,
try using a macro of the form:
Code:
Sub Witch()
Dim tbl(), i&

tbl = Range("A1:A100000")
For i = LBound(tbl, 1) To UBound(tbl, 1)
   tbl(i, 1) = Application.Hex2Dec(tbl(i, 1))
Next i
Cells(1, 1).Resize(100000) = tbl
End Sub
Best regards.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,216,039
Messages
6,128,451
Members
449,454
Latest member
khalid7977

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