[VBA] Passing formula from Cell to Array

skorpionkz

Well-known Member
Joined
Oct 1, 2013
Messages
1,168
Hi guys,

I have range with data, that I need to validate. Some of the columns have formula in it. Is there any way to pass formula itself (not result) to an array, and then array paste back to the range.

There is 2 reason why I am doing this.

1st. it is faster to loop through data to do analises.
2nd. In some cases when I receiving file, guys who creating them copying and pasting the data. sometimes they using lookup with IFERROR(....,""). The "" causing the other formulas result with the error. Adding to array and pasting back fix this problem

Thank you.
 
Last edited:

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

pgc01

MrExcel MVP
Joined
Apr 25, 2006
Messages
19,887
Hi Andrzej

To copy the formulas in a range to an array you can do a direct assignment, like:

Code:
Dim vFormulas As Variant

' write the formulas in A1:C10 into an array
vFormulas = Range("A1:C10").Formula

' display the formula in B4
MsgBox vFormulas(4, 2)
 

skorpionkz

Well-known Member
Joined
Oct 1, 2013
Messages
1,168
will this work with combined data? So let say if in first 30 columns I have static data, then in next 10 formulas and after few more static data again?

EDIT: Don't bother answering:) will test by myself:)

Thank you
Andrzej
 
Last edited:
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,164,673
Messages
5,838,705
Members
430,564
Latest member
Raeyven

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
Top