2

I would like to know if there a way to create an array which contains only formulas (not value).

for e.g.

dim myArr (1) as string
myArr(0) = "=Sum(A1:C3)"
myArr(1) = "=Sum(B1:D3)" 
Range("E1:E2") = myArr

The result is cells have above formulas as a string. is there any straightforward method of storing formulas and applying to ranges?.

thanks

1 Answer 1

2

You need to declare the array as 2D (because 1D array is a single row for Excel, and you have multiple rows), and you need to declare it as Variant.

Dim myArr(1 To 2, 1 To 1) As Variant
myArr(1, 1) = "=Sum(A1:C3)"
myArr(2, 1) = "=Sum(B1:D3)"
Range("E1:E2").Formula = myArr
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.