Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
how do i test for the existence of a range name
Hi rrobelen,
You can simply trap the error that may occur if it doesn't exist: Public Function gbDoesNameExist(rwb As Workbook, _ rsName As String) As Boolean On Error Resume Next gbDoesNameExist = Len(rwb.Names(rsName).Name) On Error GoTo 0 End Function -- Regards, Jake Marx MS MVP - Excel www.longhead.com [please keep replies in the newsgroup - email address unmonitored] rrobelen wrote: I know this must be trivial but I can't find it. How do i test to see that a range name exists? |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
how do i test for the existence of a range name
Thanks Marx
I thought there might be a simple test sort of like the iserror class of tests but I guess not. I thought of using this but was looking for the simple one. Thanks i am sure is more bullet proof then mine would have been. Again thanks for the quick response Regards Rus ----- Jake Marx wrote: ---- Hi rrobelen You can simply trap the error that may occur if it doesn't exist Public Function gbDoesNameExist(rwb As Workbook, rsName As String) As Boolea On Error Resume Nex gbDoesNameExist = Len(rwb.Names(rsName).Name On Error GoTo End Functio -- Regards Jake Mar MS MVP - Exce www.longhead.co [please keep replies in the newsgroup - email address unmonitored rrobelen wrote I know this must be trivial but I can't find it. How do i test t see that a range name exists? |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
how do i test for the existence of a range name
Hi Russ,
You could use the Evaluate function along with the TypeName function to see if you have a valid range in the active workbook: If TypeName(Evaluate("test")) = "Range" Then MsgBox "Name found" Else MsgBox "Name not found" End If If you're looking on a specific worksheet, you can do this: If TypeName(Workbooks("Book1.xls").Sheets("Sheet1" _ ).Evaluate("test")) = "Range" Then I prefer the On Error method in this case, as it allows more flexibility. -- Regards, Jake Marx MS MVP - Excel www.longhead.com [please keep replies in the newsgroup - email address unmonitored] rrobelen wrote: Thanks Marx, I thought there might be a simple test sort of like the iserror class of tests but I guess not. I thought of using this but was looking for the simple one. Thanks i am sure is more bullet proof then mine would have been. Again thanks for the quick response. Regards, Russ ----- Jake Marx wrote: ----- Hi rrobelen, You can simply trap the error that may occur if it doesn't exist: Public Function gbDoesNameExist(rwb As Workbook, _ rsName As String) As Boolean On Error Resume Next gbDoesNameExist = Len(rwb.Names(rsName).Name) On Error GoTo 0 End Function -- Regards, Jake Marx MS MVP - Excel www.longhead.com [please keep replies in the newsgroup - email address unmonitored] rrobelen wrote: I know this must be trivial but I can't find it. How do i test to see that a range name exists? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How can I test for nulls within a range without specifying each ce | Excel Discussion (Misc queries) | |||
Test within a range? | Excel Worksheet Functions | |||
Formula to test for existence of external file | Excel Worksheet Functions | |||
Test if Cell is within Range (name) | Excel Programming | |||
Testing for existence of range | Excel Programming |