[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:

Some videos you may like

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.

pgc01

MrExcel MVP
Joined
Apr 25, 2006
Messages
19,884
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:

Watch MrExcel Video

Forum statistics

Threads
1,123,525
Messages
5,602,175
Members
414,509
Latest member
Cdavis7078

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