Add additional formula's to VBA

Brentsa

Board Regular
Joined
Oct 3, 2013
Messages
87
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

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)

Brentsa

Board Regular
Joined
Oct 3, 2013
Messages
87
Office Version
  1. 365
Platform
  1. Windows
Solved I had to end the formula with """"
 
Solution

Watch MrExcel Video

Forum statistics

Threads
1,129,388
Messages
5,636,032
Members
416,892
Latest member
Bensch

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
Top