how to pass a range to a function; the starting cell is known, ending unknown

jalea148

Board Regular
Joined
Mar 23, 2012
Messages
58
The function definition looks something like
Public Function xyz(Rng as Range)​
If all the cells are defined, I can call it with
=xyz(C10:C55)
Each time xyz is required, the starting cell in the column is known, but the last defined cell in each column may change with new data. Cells before row10 and after the last one are always blank

Whenever the last cell is undefined in the call [i.e. if C55 were blank] then the cell shows #Value!.
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
What does tthe function do -- does the range contain numbers or text?
 
Upvote 0
The function definition looks something like
Public Function xyz(Rng as Range)​
If all the cells are defined, I can call it with
=xyz(C10:C55)
Each time xyz is required, the starting cell in the column is known, but the last defined cell in each column may change with new data. Cells before row10 and after the last one are always blank

Whenever the last cell is undefined in the call [i.e. if C55 were blank] then the cell shows #Value!.
Another thought ==>> let's assume C10:C55 is a range filled with dates. There are 46 dates. If
=Countif(C10:C5000,,"> 12/31/1900") + 9
is put in C9 then I would expect the following to work:
= xyz(C10:C & C9)
BUT IT FAILS. {This type of expression works in VBA in the form Range("C10:C" & C9.value}
 
Upvote 0
=xyz(C10:INDEX(C10:C5000, MATCH(9E+307, C10:C5000)))
 
Upvote 0
=xyz(C10:INDEX(C10:C5000, MATCH(9E+307, C10:C5000)))
I'm not sure what 9E or 307 represents. Index/Match appears to return a value from a table rather than the cell location in that table.
 
Upvote 0

Forum statistics

Threads
1,214,834
Messages
6,121,873
Members
449,056
Latest member
ruhulaminappu

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