VBA:从2个范围的单元格中获取范围名称

我有两个命名的范围,指的是同一个单元格,只有那个单元格。 我希望能够获得那些单元格是目标的范围的名称,但只有他们中的一个返回。

例:

命名范围'DATA_CELL'是指单元格A1。 命名范围“EVENT_CELL”是指单元格A1。

在单元格A1中检测到单击时,Target.Name.Name只返回EVENT_CELL。

如果EVENT_CELL引用多个单元格,例如A1:A3,则Target.Name.Name返回DATA_CELL。

有谁知道这是为什么,我怎么能可靠地得到这两个范围的名称引用的单元格,无论任何其他单元格的范围可能是指?

谢谢。

那么如何循环显示当前工作表中的每个名称,并仅返回与活动单元关联的消息作为消息

Sub Find_Names() ' Loop through all names in workbook. For Each n In ActiveWorkbook.Names ' Check to see if the name refers to the ActiveSheet. If InStr(1, n.RefersTo, ActiveSheet.Name, vbTextCompare) > 0 Then ' If name refers to ActiveSheet, then find the intersection of the ' named range and the ActiveCell. Set y = Intersect(ActiveCell, Range(n.RefersTo)) ' Display a message box if the ActiveCell is in the named range. If Not y Is Nothing Then MsgBox "Cell contains name : " & n.Name End If Next ' Display message when finished. MsgBox "No More Names!" End Sub