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

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
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,651
Messages
6,120,744
Members
448,989
Latest member
mariah3

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