[VBA] Passing formula from Cell to Array

skorpionkz

Well-known Member
Joined
Oct 1, 2013
Messages
1,171
Office Version
  1. 2016
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

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
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)
 
Upvote 0
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:
Upvote 0

Forum statistics

Threads
1,213,484
Messages
6,113,927
Members
448,533
Latest member
thietbibeboiwasaco

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