Dynamic named range

Formula11

Active Member
Joined
Mar 1, 2005
Messages
468
Office Version
  1. 365
Platform
  1. Windows
How can I name a range which changes.
Range is 2-dimensional. Last row and column are as shown.

I used something like this in the past for a single column.
Excel Formula:
=Sheet1!$G$1:INDEX(Sheet1!$G:$G,COUNTA(Sheet1!$G:$G))

1665916346864.png
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
You can use =Sheet1!$A$1:INDEX(Sheet1!$1:$1048576,COUNTA(Sheet1!$A:$A),COUNTA(Sheet1!$1:$1)) however, it will not work on your sample data as it is locating the row number of the last used cell in column a and the last used in row 1. You would need to make sure that those cells are always filled. You can test it by going to a blank cell and typing =name and it will display the data in your table.
 
Upvote 0
Try this ARRAY formula
Excel Formula:
=Sheet1!G2:INDIRECT("Sheet1!G"&MAX(($A$1:$G$15<>"")*(ROW($A$1:$G$15))))
OR
non volatile ARRAY formula
Excel Formula:
=Sheet1!G2:INDEX(Sheet1!G:G,MAX(($A$2:$G$15<>"")*(ROW($A$2:$G$15))))

To enter ARRAY formula
Copy and paste the formula in cell
Press F2
Press Ctrl+Shift+Enter together
Excel covers the formula with {}.
 
Upvote 0
Thanks but I couldn't get any to work.
kvsrinivasamurthy, this is for a dynamic range so last column, may be before or after "G", last row may be before of after "15".
Initial cell stays the same.
 
Upvote 0
You might want to update your profile since it determines what options are available to you.
eg the below works as in MS365 but will need to be an array formula in older versions.4

If you add the same logic for columns to @kvsrinivasamurthy's Index version and make the rows and columns bigger than you would ever need, that should work.
Excel Formula:
=Sheet1!A2:INDEX(Sheet1!$A$1:$Z$10000,
                                  MAX((Sheet1!$A$2:$Z$10000<>"")*ROW(Sheet1!$A$2:$Z$10000)),
                                  MAX((Sheet1!$A$2:$Z$10000<>"")*COLUMN(Sheet1!$A$2:$Z$10000)))
 
Upvote 0
Thanks Alex, but again it refers to an end row and end column.
I needed to use it with conditional formatting to color cells, so don't want to apply color to row 10000.
 
Upvote 0
If you put it in a named range. The named range will return the reduced range using the last row & column with data in it.
 
Upvote 0
OK thanks I'll give it a try with VBA. There are examples to find last row and column, and will need to find out how to create a name.

Also I tried to find an example of how to use a named range in conditional formatting rules but had no luck.
 
Upvote 0

Forum statistics

Threads
1,224,821
Messages
6,181,163
Members
453,021
Latest member
Justyna P

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