How to adjust this chart dynamic range to extend to the rightmost cell that contains number?

Rnkhch

Well-known Member
Joined
Apr 28, 2018
Messages
528
Office Version
  1. 365
Platform
  1. Windows
Hello,

I have the following chart dynamic range that up until now was working perfectly because I had contiguous range of numbers (E3 in the example XL2BB):

=$E$3:INDEX($E$3:$S$3,COUNT($E$3:$S$3))

However, now I have rows that do not necessarily have contiguous numbers (row 6 in the example XL2BB), and this COUNT-based formula fails (E7 in the example XL2BB). So, I'm trying to adjust the formula such that it returns the correct range (highlighted on row 8 in example XL2BB) starting from E6 to the rightmost number in row 6 including all the blank cells in between (by the way, in my real data, the blanks in the ranges are formula-based blanks, not empty blanks).

Book1
ABCDEFGHIJKLMNOPQRST
1
2Ex1contiguous numbers:36481145
3correct output36481145
4
5
6Ex2non-contiguous numbers:532
7incorrect output:50
8desired output:532
9
Sheet1
Cell Formulas
RangeFormula
E3:J3E3=$E$2:INDEX($E$2:$S$2,COUNT($E$2:$S$2))
E7:F7E7=$E$6:INDEX($E$6:$S$6,COUNT($E$6:$S$6))
Dynamic array formulas.


Thanks for any input! 🤗
 
Last edited:

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
How about this:
Book1.xlsx
ABCDEFGHIJ
1
2Ex1contiguous numbers:36481145
3correct output36481145
4
5
6Ex2non-contiguous numbers:532
7incorrect output:50
8desired output:532
Sheet2
Cell Formulas
RangeFormula
E3:J3E3=$E$2:INDEX($E$2:$S$2,COUNT($E$2:$S$2))
E7:F7E7=$E$6:INDEX($E$6:$S$6,COUNT($E$6:$S$6))
E8:J8E8=IF( $E$6:INDEX($E$6:$S$6,MAX(IF(ISNUMBER($E$6:$S$6),COLUMN($E$6:$S$6),0))-COLUMN($E$6)+1)=0, "", $E$6:INDEX($E$6:$S$6,MAX(IF(ISNUMBER($E$6:$S$6),COLUMN($E$6:$S$6),0))-COLUMN($E$6)+1) )
Dynamic array formulas.


If so, this is "shorthand" for that formula.
Book1.xlsx
DEFGHIJ
8desired output:532
Sheet2
Cell Formulas
RangeFormula
E8:J8E8=IFERROR(1/(1/($E$6:INDEX($E$6:$S$6,MAX(IF(ISNUMBER($E$6:$S$6),COLUMN($E$6:$S$6),0))-COLUMN($E$6)+1))),"")
Dynamic array formulas.
 
Upvote 0
Solution
This is fabulous! Thank you!! 🤗 Your second formula at the bottom of your post is even better. I challenged both formulas by adding extra spaces and numbers after the current ones, and I even added text to some cells, and the second formula works flawlessly.
 
Upvote 0
You're quite welcome. Thank you for the feedback! (I didn't know that the second would actually be better than the first at first glance . . . I'm now glad I chose to shorten the formula in that manner!)
 
Upvote 0
Yeah, I'm also glad you did it; it's because of the two "1/content" flips which generates errors for text cells that are subsequently converted to blanks by IFERROR.
 
Upvote 0
FWIW another option
Excel Formula:
=$E$6:INDEX($E$6:$S$6,LOOKUP(2,1/($E$6:$S$6<>""),SEQUENCE(,14)))
 
Upvote 0
Hi Fluff,

Thanks. It seems that your formula generates zeros for all the blanks? Also if there's any text, it shows the text in the output as well.
 
Upvote 0
If the cells all have formula blanks (as you stated) then you would not get zeros in the output.
Also if there's any text, it shows the text in the output as well
Not really surprising, as you never mentioned anything about text in the row. ;)

Can you post some more realistic data?
 
Upvote 0
Oh I see, right :) I decided to test text later in post #3 as extra challenge to the formulas 😅 Thank you!
 
Upvote 0

Forum statistics

Threads
1,215,066
Messages
6,122,948
Members
449,095
Latest member
nmaske

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