Using dynamic range names

Johnny C

Well-known Member
Joined
Nov 7, 2006
Messages
1,069
Office Version
  1. 365
Platform
  1. Windows
I'm trying to do a worksheetfunction.match on a range.

If I use a dynamic range name as the search array, it goes me an error. If I do it with a hard-coded range, say "V1:V50000" it works. Any idea why?

The dynamic range name is used by data validation, and that's working fine, there's no problem with the dynamic range itself.
 
Ah, I see now.

I assumed that if I know the name of the sheet which has the rangeneame defined for it then it would work, even if I don't know the name of the sheet within the dynamic range formula definition.

Unfortunately, it's not simple. The sheet that the range refers to (LookUps) gets monkeyed around with, people change the name (goodness knows why) then rename it back, and the capitalisation gets put back wrong. So it could be lookups, lookups, LOOKUPS, LookUps... even worse when the call-centre (foreign) get hold of the files. So I can't predict what the name will be, all I know is that the rangename will have the correct version encoded in. I suppose I could parse the formula in the range name defintion and extract the sheetname.
 
Upvote 0

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
Is the name defined at worksheet level or workbook level?
 
Upvote 0
Worksheet level. I can change it to workbnook level though, as the macro redefines the names each time it runs.
 
Upvote 0
No, it's OK, I just needed to know how to refer to the name:
Code:
wksdatasheet.Names("List_LOB").RefersToRange
should give the range you want.
 
Upvote 0
yes,
Code:
ActiveWorkbook.Worksheets("Query Log").Names.Add Name:="List_LOB", RefersToR1C1:="=OFFSET(LookUps!R1C18,1,0,COUNTA(LookUps!R2C18:R50000C18),1)"
for worksheet level,

Code:
ActiveWorkbook.Names.Add Name:="List_LOB", RefersToR1C1:="=OFFSET(LookUps!R1C18,1,0,COUNTA(LookUps!R2C18:R50000C18),1)"
for workbook.
 
Upvote 0
Not sure what that is in response to?
 
Upvote 0
Your previous thread about defining the names. Sorry, I was confused myself, it was more of a comment and I was changing the code as you posted to create the ranges to workbook-scope.
 
Upvote 0
OK, well if you make them workbook-level, then you refer to the name as a property of the workbook rather than sheet, but RefersToRange should still do the job.
 
Upvote 0
Mucho Gracias. I'll worry about it being pretty later, but at least I can get it working now.
 
Upvote 0

Forum statistics

Threads
1,225,149
Messages
6,183,194
Members
453,151
Latest member
Lizamaison

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