Using indirect to prevent formula cells from moving down

ehous31900

New Member
Joined
Dec 31, 2024
Messages
5
Office Version
  1. 365
  2. 2021
Platform
  1. Windows
I can not get "indirect" to work with the following formulas. It worked on a much older spread sheet that was not sorting by date or text and I assumed it would work here.

• I insert 7 to 15 rows a week by copying from a Garmin cvs export and "insert copied cells" with right click, on my new sheet.
• It is moving the 1st cell address down below the inserted.
• I thought a table and inserting one ro down leaving the top row empty would help. it did not.
• I show the non working formula in location with the " ' ".
• There is a few thousand rows already below and will have about 300 added per year.

Thank You for your help. I was so happy with the support i received a few weeks ago!


=SUMPRODUCT(INDIRECT(--(YEAR(B19:B10010)))=K2)*(INDIRECT(D19:D10010))
=SUMPRODUCT(--(YEAR(B19:B10010)=K2),--(LEFT(A19:A10010,5)="ROUVY"),D19:D10010)
#VALUE!
=AVERAGEIF(INDIRECT(--(YEAR($B$19:B10010))),2012,$M$19:$M10010)
=AVERAGEIF(INDIRECT(--(YEAR($B$19:B10010))),2012,$C$19:$C10010)
=MAXif(INDIRECT(--(YEAR($B$19:B10010))),2012,$N$19:$N10010)

1736596137953.png
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
Hi ehous31900,

It seems that you are using a table and adding rows randomly doesn't seems the best way to use it. First, I would add the data at the end, then use the filter button in the header of the table to sort by date.

Here's a solution using your table, you must change the name Table1 for your table name (top left in create table tab of the ribbon): *I am using the French version of Excel 365, so there might be some errors due to manual translation or discrepancies in the Excel user manual*

- Cell K3
Excel Formula:
=SUM(FILTER(Table1[Distance],YEAR(Table1[Date])=K2,0))

- Cell K4
Excel Formula:
=SUM(FILTER(Table1[Distance],(YEAR(Table1[Date])=K2)*(LEFT(Table1[Name],5)="ROUVY"),0))

- Cell K6
Excel Formula:
=AVERAGE(FILTER(Table1[Avg Speed],YEAR(Table1[Date])=K2,0))

- Cell K7
Excel Formula:
=AVERAGE(FILTER(Table1[Duration],YEAR(Table1[Date])=K2,0))

- Cell K8 *your screenshot show max ride miles as label while your formula is looking for max speed (N:N), so i used Distance for max distance instead of speed*
Excel Formula:
=MAX(FILTER(Table1[Distance],YEAR(Table1[Date])=K2,0))

Bests regards,

Vincent
 
Upvote 0
Solution
I would definitely be avoiding the volatile function INDIRECT if possible.

Since you are using a formal Excel table I would be using the formal table nomenclature similar to @coulombevin but below I have ..
  • Modified the formula structure so you can just copy/drag the formulas across without having to edit each one individually. As was mentioned above, check/edit the table name.
  • Replaced the zero values with "" in some so that the formulas don't incorrectly give a zero value if there is no data for that year (it may not matter with your data if there is always some data for each year listed in row 2)
I have just used Distance for my few example formulas but you should be able to apply this idea to any measures you want.

For the future I suggest that you investigate XL2BB for providing sample data to make it easier for helpers by not having to manually type out sample data to test with. ;)
(If you have trouble with XL2BB, review the "XL2BB Icons greyed out" link in the 'Known XL2BB issues' section near the top of the XL2BB Instructions page linked above.)

ehous31900.xlsm
ABCDEIJKLM
1
2Year201220132014
3Total Distance266411579
4Average Distance66.558.7142952.63636
5Max Distance929893
6
7
16
17
18NameDateDurationDistance
1916/12/201480
2013/12/201491
2112/12/201424
2211/10/201493
237/09/201449
241/09/201442
252/08/201459
2628/06/201430
2719/02/20141
2815/02/201481
2919/01/201429
3029/10/201364
3124/07/201368
3217/06/201372
3320/05/201347
3418/05/201398
3522/03/20139
369/02/201353
3731/08/201284
389/07/201292
3911/06/201222
4016/01/201268
41
42
Sheet1
Cell Formulas
RangeFormula
K3:M3K3=SUM(FILTER(Table1[[Distance]:[Distance]],YEAR(Table1[[Date]:[Date]])=K2,0))
K4:M4K4=AVERAGE(FILTER(Table1[[Distance]:[Distance]],YEAR(Table1[[Date]:[Date]])=K2,""))
K5:M5K5=MAX(FILTER(Table1[[Distance]:[Distance]],YEAR(Table1[[Date]:[Date]])=K2,""))
 
Upvote 0

Forum statistics

Threads
1,225,626
Messages
6,186,088
Members
453,336
Latest member
Excelnoob223

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