Using a formula to specify a cell reference's Row Number

Royal

New Member
Joined
Jul 15, 2011
Messages
6
I've been stumped on how to get this to work, and would appreciate any help. For a few different statistical Functions' arguments, I include two ranges (e.g., B1:B15,A1:A15). However, for each range, I need to make one of the Row Numbers -- the one to the right of the colon -- be based on the answer to this simple formula: E5+2. A friend of mine gave me a "possible syntax" that he thought might work (using the FORECAST Function as an example):

Code:
=FORECAST(E4-E3+E5,B3:'B'&E5+2,A3:'A'&E5+2)
This doesn't work, but hopefully it'll give someone an idea of what I'm trying to accomplish. I need, in this FORECAST example, for "E5+2" to equal the appropriate Row Number. I imagine this is a lot easier than it seems, but I'm no expert. Thanks in advance for anybody's help.
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
Welcome to the Board!

Take a look at INDIRECT in the helpfile. I don't have time to set the formula up for you right now, but that should do what you want.

HTH,
 
Upvote 0

Thanks a lot for that link; it was precisely what I needed to read! I wasn't sure what Function I needed to use, if any.

It frankly took me quite a while to fully process what it all meant, but eventually it clicked in my head after staring at the examples. You use quotation marks to enclose what to use exactly as-is, and use ampersands between the quoted text and the cell references.

I succeeded in using the E5+2 formula for cell rows only by assigning that to another cell: D1. So I had to do the following (this is the FORECAST example only):

Code:
=FORECAST(E4-E3+E5,INDIRECT("B3:B"&D1),INDIRECT("A3:A"&D1))
Welcome to the Board!

Take a look at INDIRECT in the helpfile. I don't have time to set the formula up for you right now, but that should do what you want.

HTH,
Unless you have a correction or critique for the above, it looks like a mission accomplished now. I appreciate the reference.
 
Upvote 0
My mind is in weekend mode and probably not functioning properly, but I think this is right

=FORECAST(E4-E3+E5,B3:INDEX(B3:B15,E5+2),A3:INDEX(A3:A15,E5+2))
 
Upvote 0
My mind is in weekend mode and probably not functioning properly, but I think this is right

=FORECAST(E4-E3+E5,B3:INDEX(B3:B15,E5+2),A3:INDEX(A3:A15,E5+2))

No; that didn't work at all. It gives me a #REF! error. I'm gonna read about the INDEX Function to see if I can use that as an alternative though.

Anyone else know any alternatives? It would be nice to do this without having to assign E5+2 to another cell for the INDIRECT Function.
 
Upvote 0
I just noticed my error, you don't need the +2 in the index version.

=FORECAST(E4-E3+E5,B3:INDEX(B3:B15,E5),A3:INDEX(A3:A15,E5))

Note that I've done the example formula for rows 3:15, If your real range is bigger then the formula will need to be adjusted.

For the syntax problem you had with indirect, the addition must be enclosed in paranthesis, INDIRECT("B3:B"&(E5+2))

Hopefully one of those should work for you.
 
Upvote 0
I just noticed my error, you don't need the +2 in the index version.

=FORECAST(E4-E3+E5,B3:INDEX(B3:B15,E5),A3:INDEX(A3:A15,E5))

Note that I've done the example formula for rows 3:15, If your real range is bigger then the formula will need to be adjusted.

Omitting the "+2" would defeat the purpose of what I'm doing, because the value of cell E5 must be summed with the number 2.

Like I posted earlier, I'm now using the INDIRECT Function to do this. I assigned the text "E5+2" to cell D1, then used the following syntax:

Code:
=FORECAST(E4-E3+E5,INDIRECT("B3:B"&D1),INDIRECT("A3:A"&D1))
This works just fine. I was just wondering if there was a alternative to having to use another cell (D1) as a reference...

For the syntax problem you had with indirect, the addition must be enclosed in paranthesis, INDIRECT("B3:B"&(E5+2))

Hopefully one of those should work for you.

...and so I'm going to try this and see if it works. I didn't think of trying to use an additional set of parenthesis for "E5+2". I'll post again later and let you know if I succeed. Thanks a lot for your input.
 
Upvote 0
And here's my second post already!

I just tried that alternative syntax for the INDIRECT Function, and it was successful! Thanks a lot!

Here's exactly what I typed (FORECAST example only):

Code:
=FORECAST(E4-E3+E5,INDIRECT("B3:B"&(E5+2)),INDIRECT("A3:A"&(E5+2)))
 
Upvote 0

Forum statistics

Threads
1,224,590
Messages
6,179,756
Members
452,940
Latest member
rootytrip

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