Array Formula and Paste

ah2024_2024

New Member
Joined
Jun 18, 2024
Messages
14
Office Version
  1. 365
Platform
  1. Windows
So, I've searched and searched and understand there are so weird things that I need to do when trying to copy and paste an array formula into VBA but man I just cannot get it. I actually have taken the coding out that I did have and now cannot remember even what I had to begin with. But below is what I have for the formula and it should copy the formula that starts in E9 and fill down to the last cell with data in A9.

wstarget.Activate

'getting call data for first day of the month
Range("E9").Select
Selection.FormulaArray = _
"=INDEX('[All Access Report - 2024 06.xlsx]Summary'!R2C[2]:R200C[2],MATCH(1,R6C[-1]='[All Access Report - 2024 06.xlsx]Summary'!R1C[1])*(RC1='[All Access Report - 2024 06.xlsx]Summary'!C2),0)"


Application.ScreenUpdating = True
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
Here is the formula that goes with the above:
=INDEX('[All Access Report - 2024 06.xlsx]Summary'!G$2:G$200,MATCH(1,D$6='[All Access Report - 2024 06.xlsx]Summary'!F$1)*($A9='[All Access Report - 2024 06.xlsx]Summary'!$B:$B),0)
 
Upvote 0
Step 1 before getting your formula to work in VBA is to make sure it works in Excel.
I don't believe your formula works.
Leaving out the workbook reference I think its most likely meant to be:
Rich (BB code):
=INDEX(Summary!G$2:G$200,MATCH(1, ( D$6=Summary!F$1 )*($A9=Summary!$B2:$B200),0))
The RC format has some additional issues

Assuming the above to be the case, try this:
VBA Code:
Sub InsertFormula()

    Dim ws As Worksheet
    Dim sFormula As String
    Dim LastRow As Long
    
    Set ws = ActiveSheet
    With ws
        LastRow = .Range("A" & Rows.Count).End(xlUp).Row
    End With
    
    sFormula = "=INDEX('[All Access Report - 2024 06.xlsx]Summary'!R2C[2]:R200C[2],MATCH(1,(R6C[-1]='[All Access Report - 2024 06.xlsx]Summary'!R1C[1])*(RC1='[All Access Report - 2024 06.xlsx]Summary'!R2C2:R200C2),0))"
    ws.Range("E9:E" & LastRow).Formula2R1C1 = sFormula

End Sub
 
Upvote 0

Forum statistics

Threads
1,223,164
Messages
6,170,444
Members
452,326
Latest member
johnshaji

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