Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vba 如何检查单元格是否属于动态名称范围_Vba_Excel - Fatal编程技术网

Vba 如何检查单元格是否属于动态名称范围

Vba 如何检查单元格是否属于动态名称范围,vba,excel,Vba,Excel,我有几个动态名称范围,我想在VBA中检查一个单元格(活动单元格除外)是否属于其中一个 例如,我创建了namerange nameTest1=OFFSET(A1;0;0;COUNT(A1:A12)) 我想检查活动单元格是否在这个范围内 我已经找到了各种方法来实现这一点,但在动态名称范围上没有 有办法吗 问候 Thanasis要进行测试,nameTest1是一个命名范围 If Not Application.Intersect(ActiveCell, Range("nameTest1")) Is

我有几个动态名称范围,我想在VBA中检查一个单元格(活动单元格除外)是否属于其中一个

例如,我创建了namerange

nameTest1=OFFSET(A1;0;0;COUNT(A1:A12))
我想检查活动单元格是否在这个范围内

我已经找到了各种方法来实现这一点,但在动态名称范围上没有

有办法吗

问候


Thanasis要进行测试,nameTest1是一个命名范围

If Not Application.Intersect(ActiveCell, Range("nameTest1")) Is Nothing Then
    MsgBox "activecell is in range nameTest1"
Else
    MsgBox "activecell is not in range nameTest1"
End If

要进行测试,nameTest1是一个命名范围

If Not Application.Intersect(ActiveCell, Range("nameTest1")) Is Nothing Then
    MsgBox "activecell is in range nameTest1"
Else
    MsgBox "activecell is not in range nameTest1"
End If

要确定活动单元格所属的命名范围,请尝试以下操作

For Each nr In ActiveWorkbook.Names 
  If Not Application.Intersect(ActiveCell, Range(nr.Name)) Is Nothing Then 
   MsgBox "activecell intersect with " & nr.Name 
 End If 
Next 

要确定活动单元格所属的命名范围,请尝试以下操作

For Each nr In ActiveWorkbook.Names 
  If Not Application.Intersect(ActiveCell, Range(nr.Name)) Is Nothing Then 
   MsgBox "activecell intersect with " & nr.Name 
 End If 
Next 

我稍微调整了一下h2so4溶液:

For Each nr In ActiveWorkbook.Names
    On Error Resume Next
    If Not Application.Intersect(ActiveCell, Range(nr.Name)) Is Nothing Then
        If Err.Number = 0 Then
            MsgBox "activecell intersect with " & nr.Name
        End If
    End If
    Err.Clear
Next 

谢谢你的帮助

我稍微调整了一下h2so4溶液:

For Each nr In ActiveWorkbook.Names
    On Error Resume Next
    If Not Application.Intersect(ActiveCell, Range(nr.Name)) Is Nothing Then
        If Err.Number = 0 Then
            MsgBox "activecell intersect with " & nr.Name
        End If
    End If
    Err.Clear
Next 

谢谢你的帮助

使用
Intersect
方法?不确定为什么它会与任何其他范围不同-您尝试了哪些方法?使用
Intersect
方法?不知道为什么它会与其他任何系列有所不同-您尝试过哪些方法?是的,这很有效。谢谢是否有方法检查单元格是否属于动态名称范围,如果是,该范围的名称是什么?
对于ActiveWorkbook中的每个nr。如果不是应用程序,则名称。Intersect(ActiveCell,范围(nr.name))为空,然后MsgBox“ActiveCell Intersect with”&nr。如果下一步是,则名称结束。谢谢是否有方法检查单元格是否属于动态名称范围,如果是,该范围的名称是什么?
对于ActiveWorkbook中的每个nr。如果不是应用程序,则名称。Intersect(ActiveCell,范围(nr.name))为空,然后MsgBox“ActiveCell Intersect with”&nr。如果下一个