Combining/nesting formulas

Ljerrett

New Member
Joined
Oct 18, 2024
Messages
4
Office Version
  1. 2016
Platform
  1. Windows
Need help with a Google sheets formula.

=AVERAGE(OFFSET(GV2,3,-5,1,5))
Gives me the answer I want, (an average of the last five days closing price on my stock), but the cell GV2/closing price is dynamic, so that is the cell with the right information for today but it will not be the correct cell for tomorrow... So instead of having to change my formula every day to reflect the correct cell/number, I want to replace the GV2 in the formula with a cell that is always TODAY.

=XMATCH(TODAY(),2:2,0)
Gives the cell that is TODAY()

The problem: When I paste XMATCH(TODAY(),2:2,0) overtop where the GV2 is in the first formula, it does not work. It is probably something simple like I need another parenthesis somewhere, but I can not figure out how to nest these two formulas.

Right now, this is what I have
=AVERAGE(OFFSET(XMATCH(TODAY(),2:2,0),3,-5,1,5))

error message says: The argument must be a range

Any help from my brainy friends would be greatly appreciated.
 
Last edited by a moderator:

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
What version of Excel are you using? As 2016 does not have XMATCH.
I suggest that you update your Account details (or click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)
 
Upvote 0
Welcome to the Board!

Also note that the first argument in the OFFSET function MUST be a range (like GV2) -- this is your starting point.
You are telling Excel start in this cell, then move some number of rows up/down and some number of columns to the left/right.
TODAY() is a number (date), not a range.

See here for details on the OFFSET function.
 
Upvote 0
What version of Excel are you using? As 2016 does not have XMATCH.
I suggest that you update your Account details (or click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)
I put Excel 2016 because that's what I have on my computer but I forgot that I'm actually doing this formula on Google sheets via my computer.
 
Upvote 0
I believe XLookup in Google Sheets is the same as in Excel in that it returns a Range Object not just the Range Value, so try this:
(XMatch will just return a position number)

Excel Formula:
=AVERAGE(OFFSET(xlookup(today(),2:2,2:2),3,-5,1,5))
 
Upvote 0
I believe XLookup in Google Sheets is the same as in Excel in that it returns a Range Object not just the Range Value, so try this:
(XMatch will just return a position number)

Excel Formula:
=AVERAGE(OFFSET(xlookup(today(),2:2,2:2),3,-5,1,5))
 
Upvote 0
Do you want to share a sample using either XL2BB or something like Google drive ?
(If using a sharing platform make sure to give access to anyone with the link and post the link here)
 
Upvote 0

Forum statistics

Threads
1,224,816
Messages
6,181,143
Members
453,021
Latest member
Justyna P

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