
thanks Joel, that is exactly what I came up with while poking around..
If Left(Nam, 5) = "=#REF" Then
Nam.Delete
End If
Bernie, I would think that if you deleted a sheet that the names would be
deleted also, but when I go to INSERT-NAME-DEFINE, they are still listed jst
with bad references. This was making other macros I had mess up as it was
still going through old names and giving me bogus values..
This will work for though... Thanks guys!!!
"Joel" wrote:
> For Each Nam In ActiveWorkbook.Names
> If Left(Nam.Value, 5) = "=#REF" Then
> 'put your code here
> End If
> Next Nam
>
> "Kevin" wrote:
>
> > If I have several named cells in say 10 worksheets, and I delete sheet 8,
> > then I have some named ranged left out there with no valid reference.
> >
> > How can I check the validity of a named cell in vba? I have this so far...
> >
> > Sub test()
> > Dim Nam As Name
> > For Each Nam In ActiveWorkbook.Names
> >
> > "Place code here to check if reference on name is good, if it isnt then
> > delete that name."
> >
> > Next Nam
> > End Sub
> >
> > Thanks in advance