Add additional formula's to VBA

Brentsa

Board Regular
Joined
Oct 3, 2013
Messages
118
Office Version
  1. 365
Platform
  1. Windows
I have the follwing VBA Code:

VBA Code:
'Create Formula in AB1:AD1
    Dim LR As Long
    
    LR = Cells(Rows.Count, "AA").End(xlUp).Row
    With Range("AB1:AB" & LR)
        .FORMULA = "=IFERROR(INDEX('Teller Stats'!C6,AGGREGATE(15,6,ROW('Teller Stats'!C6)/((('Teller Stats'!C9=Balance!RC27)+('Teller Stats'!C10=Balance!RC27))>0)/ISNA(MATCH('Teller Stats'!C6,Balance!RC27:RC[-1],0)),1)),"""")"
        .NumberFormat = "0"
       End With
End Sub

When I try to add additional formulas to the VBA Code the VBA throws out a error:

1614167093429.png


VBA Code:
'Create Formula in AB1:AD1
    Dim LR As Long
    
    LR = Cells(Rows.Count, "AA").End(xlUp).Row
    With Range("AB1:AB" & LR)
        .FORMULA = "=IFERROR(INDEX('Teller Stats'!C6,AGGREGATE(15,6,ROW('Teller Stats'!C6)/((('Teller Stats'!C9=Balance!RC27)+('Teller Stats'!C10=Balance!RC27))>0)/ISNA(MATCH('Teller Stats'!C6,Balance!RC27:RC[-1],0)),1)),"""")"
        .NumberFormat = "0"
       End With
       
   LR = Cells(Rows.Count, "AA").End(xlUp).Row
    With Range("AC1:AC" & LR)
        .FORMULA = "=IFERROR(@INDEX('Teller Stats'!$F:$F,AGGREGATE(15,6,ROW('Teller Stats'!$F:$F)/((('Teller Stats'!$I:$I=Balance!$AA1)+('Teller Stats'!$J:$J=Balance!$AA1))>0)/ISNA(MATCH('Teller Stats'!$F:$F,Balance!$AA1:AB1,0)),1)),"")"
        .NumberFormat = "0"
       End With
             
       
End Sub

I want the VBA Code to place the following formulas in:

AB: =IFERROR(@INDEX('Teller Stats'!$F:$F,AGGREGATE(15,6,ROW('Teller Stats'!$F:$F)/((('Teller Stats'!$I:$I=Balance!$AA1)+('Teller Stats'!$J:$J=Balance!$AA1))>0)/ISNA(MATCH('Teller Stats'!$F:$F,Balance!$AA1:AA1,0)),1)),"")

AC: =IFERROR(@INDEX('Teller Stats'!$F:$F,AGGREGATE(15,6,ROW('Teller Stats'!$F:$F)/((('Teller Stats'!$I:$I=Balance!$AA1)+('Teller Stats'!$J:$J=Balance!$AA1))>0)/ISNA(MATCH('Teller Stats'!$F:$F,Balance!$AA1:AB1,0)),1)),"")

AD: =IFERROR(@INDEX('Teller Stats'!$F:$F,AGGREGATE(15,6,ROW('Teller Stats'!$F:$F)/((('Teller Stats'!$I:$I=Balance!$AA1)+('Teller Stats'!$J:$J=Balance!$AA1))>0)/ISNA(MATCH('Teller Stats'!$F:$F,Balance!$AA1:AC1,0)),1)),"")

and for them to run to the last entry in column AA
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)

Forum statistics

Threads
1,212,927
Messages
6,110,720
Members
448,294
Latest member
jmjmjmjmjmjm

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