VBA Code Runtime Error

soumen21

New Member
Joined
Aug 16, 2019
Messages
29
I'm using the following formula in a cell
=IFERROR(INDEX($A$1:$A$33,AGGREGATE(15,6,(ROW($A$1:$A$33)/(($B$1:$B$33>=$I$1)*($B$1:$B$31<$J$1))),ROWS($A$1:$A2)-ROW($A$1))),"")
It works perfectly.

If i enter the same formula in my vba code, I get run time error. How to correct it. In vba code i wrote

Worksheets("Sheet2").Range("T10").Formula = "=IFERROR(INDEX.$A$1:$A$33,AGGREGATE(15,6,(ROW($A$1:$A$33)/(($B$1:$B$33>=$I$1)*($B$1:$B$31<$J$1))),ROWS($A$1:$A2)-ROW($A$1))),"")"

What more I have to add, modify?
Also what shall I do to run the same formula with increments throughout T10-T40



Regards
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
How about
Code:
Worksheets("Sheet2").Range("T10:T40").Formula = "=IFERROR(INDEX($A$1:$A$33,AGGREGATE(15,6,(ROW($A$1:$A$33)/(($B$1:$B$33>=$I$1)*($B$1:$B$31<$J$1))),ROWS($A$1:$A2)-ROW($A$1))),"""")"
 
Upvote 0
Try: Worksheets("Sheet2").Range("T10").Formula = "=IFERROR(INDEX.$A$1:$A$33,AGGREGATE(15,6,(ROW($A$1:$A$33)/(($B$1:$B$33>=$I$1)*($B$1:$B$31<$J$1))),ROWS($A$1:$A2)-ROW($A$1))),"""")"
 
Upvote 0
Glad we could help & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,214,606
Messages
6,120,483
Members
448,967
Latest member
visheshkotha

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