MartinS
Active Member
- Joined
- Jun 17, 2003
- Messages
- 490
- Office Version
- 365
- Platform
- Windows
Hi
Odd one. I have a function in a template workbook that checks for the existence of a sheet level range name, and in one instance, it is returning True when the name does not exist in the list of names.
In this instance, shtDA is a worksheet named "DA-LVDate Basis", and these are all the names that show in the list of workbook names:
The first line in my code example returns True, causing the code inside the If to fail - the first line is returning the value of the RefersToRange, which errors.
Is there any way I can figure out why the error is happening, or a neater approach to the test?
Many thanks
Martin
Odd one. I have a function in a template workbook that checks for the existence of a sheet level range name, and in one instance, it is returning True when the name does not exist in the list of names.
VBA Code:
If NamedRangeExistsInWorksheet(shtDA, strTablePrefix & cSfxStartPoint) Then
...
Public Function NamedRangeExistsInWorksheet(sht As Worksheet, strName As String) As Boolean
If VarType(sht.Evaluate(strName)) <> vbError Then NamedRangeExistsInWorksheet = True
End Function
The first line in my code example returns True, causing the code inside the If to fail - the first line is returning the value of the RefersToRange, which errors.
Is there any way I can figure out why the error is happening, or a neater approach to the test?
Many thanks
Martin