Forum Discussion
Mike_Motek
Jan 24, 2023Copper Contributor
Sorting and named ranges
This problem relates to an Excel 2010 workbook I have created for recording bird banding data. Bird bands come in multiple sizes and each species can use one or more sizes.
I have a worksheet that defines the characteristics of each species, including the band size(s) that are appropriate for each species. The species are identified by a unique 4 character code. From this I have built a named range for each species that maps the appropriate sizes for that species.
When the banding data is entered on a different worksheet I check the size of the range and, if there is only 1 entry, prefill it, otherwise the validation rule uses the list as a dropdown limited to the appropriate sizes. This has been working well for the past 2 years. Yesterday while working on the system I came across an issue I hadn't considered - what happens to the named ranges when the species table is sorted (the lists lose their association with the species).
At the moment the named ranges use absolute references, I tried using relative ranges but that didn't work either. The only things I can think of to address this issue are:
1) Protecting the species worksheet to disable sorting
2) Detecting the sort and rebuilding the lists using visual basic (I use VB to build the lists so I'd simply repurpose that code). Unfortunately I don't see an on sort event so I think I'm restricted to an the worksheet deactivate event.
Are there any other suggestions?
Thanks
Mike
No RepliesBe the first to reply