VBA help needed to get FormulaArray from cell value

Akbarov

Active Member
Joined
Jun 30, 2018
Messages
347
Office Version
  1. 365
Platform
  1. Windows
Hello Dear community,

I have cells with array formulas I used sign ' to store them as text. So depending on users choice VBA needs to insert that array formula to cell AA10.
Example, this formula is in range A4:
'='sales data'!AA10*RAND()*10000000

I want to insert this array formula to sheet ws.range("AA10")
I used this code:
VBA Code:
ws.Range("AA10").FormulaArray = Sheets("ArrayBackend").Range("A" & Cell.Row).Offset(, 1).Formula
'And also tried'
ws.Range("AA10").FormulaArray = Sheets("ArrayBackend").Range("A" & Cell.Row).Offset(, 1).value

But it doesn't works. Can anyone help me please?
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
I do not think this:
='sales data'!AA10*RAND()*10000000
is an array formula.

May be try with .Formula only?
ws.Range("AA10").Formula = ...
 
Upvote 0
Hello bebo, thanks for reply, but problem is , it is in most times array, but sometimes regular formula.
 
Upvote 0
A couple of questions:
1) If it's in cell A4, why do you need Range("A" & Cell.Row).Offset(, 1)?
2) What does the "doesn't work" mean?
 
Upvote 0
Thanks for reply. I could figure out how to make it can work. Used IF statement to check whether cell hasFormula or hasArray.
And yes formulas actually on column B, that's why I used offset.
VBA Code:
         If Sheets("ArrayBackend").Range("A" & Cell.Row).Offset(, 1).HasArray = True Then
                            ws.Range("AA10").FormulaArray = Sheets("ArrayBackend").Range("A" & Cell.Row).Offset(, 1).FormulaArray
                            Sheets("ArrayBackend").Calculate
                            ElseIf Sheets("ArrayBackend").Range("A" & Cell.Row).Offset(, 1).HasFormula = True Then
                            ws.Range("A10:" & Cells(LR, LC).Address).Formula = Sheets("ArrayBackend").Range("A" & Cell.Row).Offset(, 1).Formula
                            End If
 
Upvote 0

Forum statistics

Threads
1,215,129
Messages
6,123,218
Members
449,091
Latest member
jeremy_bp001

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