INDEX Function gives #REF! Error on worksheet and Error 2023 in UDF

narendra

Board Regular
Joined
Apr 15, 2008
Messages
95
I am not sure what is causing below error, it seems my mind has stopped thinking ... it's been a long day.

Wrapping below FORMULA in a SUM function gives me #REF error in excel. The formula with SUM is in cell E4.
Code:
INDEX(A:C,ROW())
The column reference is omitted as I want it to return all 4 columns.

Ideally, the above part should return Range A4:C4 which is filled with numeric values and the SUM function should return the total of those values, but i get the #REF error.


I am testing above function on a worksheet because the same INDEX formula when passed to a UDF returned #VALUE error.
The above part was passed to the 1st argument in the UDF which is declared As Range.

When I entered the formula, it did not even trigger the breakpoint I set at the very beginning of the UDF code.
I had to remove the As Range declaration from the 1st argument which then triggered the breakpoint. Mouse over the 1st argument showed Error 2023.

Note: The UDF works fine when only one column is selected.

Can someone please let me know what is wrong here?
 
Last edited:

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
To return all columns, you'll need to specify the third argument for your INDEX function as 0. In a worksheet formula, you would do the followIng...

Code:
=SUM(INDEX(A:C,ROW(),0))

Hope this helps!
 
Upvote 0

Forum statistics

Threads
1,223,896
Messages
6,175,259
Members
452,626
Latest member
huntinghunter

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