Copy formulas from a range to variant array

Viewed 15

I want to copy all the range's contents in the array and then back to the range.

Dim arr As Variant
Dim r as Range
Set r = ActiveSheet.ListObjects(1).DataBodyRange
arr = r.Value2
r.Value2 = arr

I found out that statement arr = r.Value2 doesn't store equations but their values in an array. So after the statement r.Value2 = arr does it's job, equations are gone form the worksheet.

How can I store equations in array and then copy them back?

1 Answers

When you are using arr = r.Value2 it is storing only values from range to variant array. Again you are transferring those values to cells. To store formula instead of values use-

arr = r.Formula
Related