Home » excel » excel – How can I expand a dynamic range with blanks between cells?

excel – How can I expand a dynamic range with blanks between cells?

Posted by: admin May 14, 2020 Leave a comment


I want to define a dynamic range that will expand the rows and columns of my range whenever a new row or column is inserted. My current formula does not want to expand to cell $T$13. My headers start in row $M$7. How can I adjust my formula?

Formula Being Used


I need my range to expand to cell $T$13

enter image description here

How to&Answers:

Right now, your formula counts the number of text values in column M.

That is not a robust approach because column M contains only five text values, but columns S and T have many more values.

If you don’t know which column may have the most number of entries, you can introduce a helper cell in each column that counts the number of entries below. I suggest you insert a new row 2. In column M, for example, put a formula in M2


Copy that formula across to column T.

Next you can evaluate which of the columns has the largest number


This can be plugged into your original formula like this:


So now, instead of just looking at how many rows are in column M, the formula uses the maximum number of rows in the columns M to S.

You can now hide row 2 if it upsets your worksheet design.

Edit: the mere count of text values with CountA will ignore blank cells and will return incorrect results. You really need a formula to find the row number of the last populated cell in each column.

This should really be a new question, but here goes

If the column has number values you can use


If the column has text values you can use


Adjust your ranges accordingly.


I ended up using the solution mentioned by @tevlyn.

In range$M2:$T2

I have the follolwing formula =IFERROR(MATCH(99^99,M$8:M$999,1),0).

I’ve added IFERROR because my data doesn’t always have data stretched to $T2.

I then defined my range in name manager using:


This still works even if there are blanks in between the range.