Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have some named ranges (no more than 15) in a workbook and I am assigning
their values to string variables. For some reason my named ranges are randomly disappearing after my code runs. The syntax in VBA looks like this: strDate = Worksheets("SheetName").Range("NamedRange1").Value Any ideas????? |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Are you deleting the cells of the named range somewhere in your code? The
named range will refer to 'Worksheet Name'!#REF! after the delete, and will be invalid the next time you try to use it. You will have to step through all of your code to figure out where this is happening. You might consider including an error hander and doing it like this: Public Sub Test() Dim rngNamedRange As Range On Error Resume Next Set rngNamedRange = ThisWorkbook.Names("NamedRange").RefersToRange If rngNamedRange Is Nothing _ Then MsgBox "'NamedRange' has disappeared!", vbCritical + vbOKOnly Else 'Continue processing. End If End Sub -- Regards, Bill Renaud |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
In article ,
Mike wrote: I have some named ranges (no more than 15) in a workbook and I am assigning their values to string variables. For some reason my named ranges are randomly disappearing after my code runs. I have seen this happen recently, but only once. I don't know whether the disappearance was related to code running or not. -- David J Richardson -- http://davidj.richardson.name/ - Dr Who articles/interviews/reviews http://www.boomerang.org.au/ - Boomerang Association of Australia |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Excel 2007 Named Ranges | Excel Discussion (Misc queries) | |||
Named Ranges Disappearing in Excel 2007 | Excel Discussion (Misc queries) | |||
Named ranges disappearing in Excel 2007 | Excel Discussion (Misc queries) | |||
Named ranges in Excel 2007 | Excel Discussion (Misc queries) | |||
Excel 2007 Beta-Named Ranges | Excel Discussion (Misc queries) |