Hey, I'm hoping someone has a quick fix for this situation. I have a macro that renames specific named range names from a list. In the spreadsheets I run this against, there may be 10,000+ named ranges so it takes way too long to search my Named range Variant to locate the one to change. In order to rename a Named Range name without losing the RefersTo: part of it, I load a variant like ListOfNames = Activeworkbook.Names then use an index like ListofNames(Pointer) = NewNRName to rename it.
I'm using a binary subroutine to more quickly locate the matching entry in the ListOfNames, but I have run into a snag with names that contain numbers.
The ListOfNames table is automatically sorted when produced in such as way that "zzz_item_2_data" comes before "zzz_item_20_data". But when I run the routine, every comparison I use results in that first one being greater than the second item.
So lets say:
Needle = "zzz_item_2_data"
Haystack = "zzz_item_20_data"
StrComp(Needle,Haystack,vbBinaryCompare)
StrComp(Needle,Haystack)
If Needle < Haystack
all say Needle is greater than Haystack.
I know the issue is the "0" after the 2 on Haystack but need a way to cause the compares to give the same positioning as ListOfNames.
Any ideas? Thanks!
I'm using a binary subroutine to more quickly locate the matching entry in the ListOfNames, but I have run into a snag with names that contain numbers.
The ListOfNames table is automatically sorted when produced in such as way that "zzz_item_2_data" comes before "zzz_item_20_data". But when I run the routine, every comparison I use results in that first one being greater than the second item.
So lets say:
Needle = "zzz_item_2_data"
Haystack = "zzz_item_20_data"
StrComp(Needle,Haystack,vbBinaryCompare)
StrComp(Needle,Haystack)
If Needle < Haystack
all say Needle is greater than Haystack.
I know the issue is the "0" after the 2 on Haystack but need a way to cause the compares to give the same positioning as ListOfNames.
Any ideas? Thanks!