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: 7

Some videos you may like

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off

Habtest

Board Regular
Joined
Jul 30, 2020
Messages
74
Office Version
  1. 365
Platform
  1. Windows
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))
 
Solution

psg2002

New Member
Joined
Feb 14, 2021
Messages
8
Office Version
  1. 365
Platform
  1. Windows
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!!
 

Watch MrExcel Video

Forum statistics

Threads
1,127,730
Messages
5,626,552
Members
416,190
Latest member
plee3

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
Top