Hi,
I like to define a dynamic range in the define name window as follows
This works fine as long as all the cells in col A and row 1 are filled.=Offset($A$1,0,0,Counta($A:$A),Counta($1:$1)
If this is not the case I have defined the range in VBA. using rows.count and columns.count
I now have a situation where I would like to define a dynamic range which may easily have lots of empty cerlls using the define name window. I have not been able to find worksheet functions to do the job.
Can anyone help please
John
Last edited by j_Southern; 02-13-2012 at 09:57 AM.
Try this
=OFFSET($A$1,0,0,MATCH(REPT("z",99),$A:$A),MATCH(REPT("z",99),$1:$1))
Hi,
Thanks for your help, but that doesn't work.
John
What kind of data do you have in Column A and Row 1?
Microsoft MVP - Excel
Where there is a will there are many ways. Pick One!
Please read the Forum Rules
If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below
Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.
Preferred Charities: Lupus Canada and Sick Kids Foundation.
Feel Free to Donate if you want to, for the assistance you received today.
A mixture of strings and numbers and blanks
John
Try:
This takes into account that it might be possible to have only text (and blanks) or only numbers (and blanks) too...=Sheet1!$A$1:INDEX(Sheet1!$1:$1048576,MAX(IFERROR(MATCH(9.999E+307,Sheet1!$A:$A),0),IFERROR(MATCH(REPT("z",255),Sheet1!$A:$A),0)),MAX(IFERROR(MATCH(9.999E+307,Sheet1!$1:$1),0),IFERROR(MATCH(REPT("z",255),Sheet1!$1:$1),0)))
Microsoft MVP - Excel
Where there is a will there are many ways. Pick One!
Please read the Forum Rules
If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below
Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.
Preferred Charities: Lupus Canada and Sick Kids Foundation.
Feel Free to Donate if you want to, for the assistance you received today.
Thank you all for your help. Both methods work. I shall use the shorter one.
It does seem odd that there isn't a function like VBA CurrentRegion which would make it easier to name a range containing blank cells..
John
Though note that shorter isn't always most ideal.. some functions are Volatile....
Microsoft MVP - Excel
Where there is a will there are many ways. Pick One!
Please read the Forum Rules
If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below
Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.
Preferred Charities: Lupus Canada and Sick Kids Foundation.
Feel Free to Donate if you want to, for the assistance you received today.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks