How to change row number in function based on a value change

psg2002

New Member
Joined
Feb 14, 2021
Messages
8
Office Version
  1. 365
Platform
  1. Windows
Hi,

I'm trying to calculate the difference between 2 ranges (each range is in a different tab). I have a table that generates values and I want my function to be able to change the row value based on the return value in the table.

For example, on cell C5, I have the formula '=AVERAGE(Data1!A2:C2)-AVERAGE(Data2!A2:C2)'

If one of the table values, cell H5 returns the value '5', I want my functionion to pick up the value and change the formula to

'=AVERAGE(Data1!A5:C5)-AVERAGE(Data2!A5:C5)'

Is this possible to achieve? thank you so much in advance.
 

Attachments

  • excel_screenshot.png
    excel_screenshot.png
    24.3 KB · Views: 17

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
Hi there, if I understand correctly, INDIRECT will work, here is an example:

Book1
ABCDEF
1ABC
2123Row2
3234Result2
4345
5456
6567
Sheet1
Cell Formulas
RangeFormula
F3F3=AVERAGE(INDIRECT("Sheet1!A"&F2,TRUE):INDIRECT("Sheet1!C"&F2,TRUE))
 
Upvote 0
Solution
Hi there, if I understand correctly, INDIRECT will work, here is an example:

Book1
ABCDEF
1ABC
2123Row2
3234Result2
4345
5456
6567
Sheet1
Cell Formulas
RangeFormula
F3F3=AVERAGE(INDIRECT("Sheet1!A"&F2,TRUE):INDIRECT("Sheet1!C"&F2,TRUE))
This is perfect! Thank you merci!!
 
Upvote 0

Forum statistics

Threads
1,214,944
Messages
6,122,391
Members
449,080
Latest member
Armadillos

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