I know the exact cell, but I can't get VBA to return the named range that is defined for this cell. I've seem examples on other posts for doing this, but I'm getting a 1004 error: "Application-defined or Object-defined error".
I wrote code to select the cell and then ran this code.
The error occurs on the line "set rng = Intersect(..........).
Any ideas on how to get the named range for a specified cell would be greatly appreciated.
Thanks!!!
I wrote code to select the cell and then ran this code.
Code:
For Each nm In ThisWorkbook.Names
Set rng = Intersect(ActiveCell, Range(nm.RefersToRange.Address))
If Not rng Is Nothing Then
MsgBox ActiveCell.Address & " is in the named range " & nm.Name
Exit For
End If
Next nm
The error occurs on the line "set rng = Intersect(..........).
Any ideas on how to get the named range for a specified cell would be greatly appreciated.
Thanks!!!