Dynamic ranges

Lolo13

New Member
Joined
Sep 7, 2021
Messages
5
Office Version
  1. 365
Platform
  1. Windows
Hi, i have created multiple dynamic ranges using the offset function and these ranges are working fine; for instance, range1, range , range 3, etc... All these ranges contain numbers.
If i do a sum(range1) i do get the proper sum of values contained in range1. However, instead of calling directly the range in the sum function as previously mentioned i need to call it from a cell, see below for clarity:
1631041241096.png

So the first two lines are working fine but somehow i cannot refer to a working range via a cell content... Is there a workaround ?
Thanks.
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
Welcome to the MrExcel forum!

It works for me, what are you getting as a result?

Book1 (version 1).xlsb
ABCDEF
1range110122
2range217234
3range320356
4478
Sheet6
Cell Formulas
RangeFormula
B1B1=SUM(Range1)
B2B2=SUM(Range2)
B3B3=SUM(INDIRECT(A3))
Named Ranges
NameRefers ToCells
Range1=Sheet6!$D$1:$D$4B1
Range2=Sheet6!$E$1:$E$4B2
 
Upvote 0
it works because you are not using dynamic ranges. Here is what i want to do using your example:

1631043748615.png


and actual results:
1631043780177.png
 

Attachments

  • 1631043581877.png
    1631043581877.png
    19.3 KB · Views: 3
Upvote 0
Sorry on my previous post, the results look like this:
1631044315427.png
 
Upvote 0
Sorry, I missed that part. I replicated your issue on my sheet. I've poked around a bit, and can't explain it. =SUM(Range1) works, but ROWS(Range1) doesn't. I've tried rewriting your dynamic formulas using INDEX instead of OFFSET, but that didn't help either. I'll see what else I can come up with.
 
Upvote 0
Thanks, i have been banging my head for hours on this ... It seems like such a "trivial" issue....
 
Upvote 0
I've tried a few more things, and come up empty. I did a web search, and found people asking this question for over 10 years, and no one's had an answer. Just something Microsoft has never gotten around to fixing. One poster mentioned that you can use INDIRECT with tables, although you might not be able to change your sheet to make that work. You might be able to get away with using static ranges. For example, if Range2 is defined as: =OFFSET(Sheet6!$E$1,0,0,COUNT(Sheet6!$E$1:$E$10)), the COUNT function counts the number of numeric values. If you change Range2 to be =$E$1:$E$10, and use =SUM(INDIRECT(A2)), it works. SUM only adds up numeric values anyway, so keeping the whole range won't affect the result. But that depends on what you use your dynamic named ranges for.

Again, depending on your layout, something like this:

Book1 (version 1).xlsb
ABCDEF
1Range110Range1Range2Range3
2Range217122
3Range330234
4356
5478
610
7
Sheet6
Cell Formulas
RangeFormula
B1:B3B1=SUM(INDEX($D$2:$F$10,0,MATCH(A1,$D$1:$F$1,0)))
Named Ranges
NameRefers ToCells
Range1=OFFSET(Sheet6!$D$2,0,0,COUNTA(Sheet6!$D$2:$D$11))B1:B3
Range2=OFFSET(Sheet6!$E$2,0,0,COUNT(Sheet6!$E$2:$E$11))B1:B3
Range3=Sheet6!$F$2:INDEX(Sheet6!$F$2:$F$11,COUNT(Sheet6!$F$2:$F$11))B1:B3


So there's probably a way to do what you want, but you may need to change things around some, and it won't involve INDIRECT with DNRs. :(
 
Upvote 0
Thanks a bunch for looking inti this Eric! :) Unfortunately though, really need dynamic ranges for my application. Moreover, I was just using SUM as an example;in reality i am using a custom function that is even more complicated....
In any case, thanks for your time!
 
Upvote 0
Is it a custom function built from spreadsheet functions, or a UDF built from VBA? If from VBA, you can use something like:

range(range("A3")).Address

to get the address of the dynamic range, and insert that into later functions.

Anyway, sorry I wasn't more help, but good luck!
 
Upvote 0

Forum statistics

Threads
1,214,392
Messages
6,119,255
Members
448,879
Latest member
oksanana

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