Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/vba/17.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 - Fatal编程技术网

Vba 当活动单元格位于特定列上时运行宏

Vba 当活动单元格位于特定列上时运行宏,vba,Vba,我想在活动单元格仅位于G、Q和Z列时运行宏。 我怎样才能把它缩小到只在这3列上运行,而不在G到Z的范围内? 试图设置3个不同的目标地址,但没有成功 If Selection.Cells.Count = 1 Then Set A = Application.Intersect(Range(Target.Address), Range("G4:Z2500")) If Not A Is Nothing Then Call macro Else: Call Delete

我想在活动单元格仅位于G、Q和Z列时运行宏。 我怎样才能把它缩小到只在这3列上运行,而不在G到Z的范围内? 试图设置3个不同的目标地址,但没有成功

If Selection.Cells.Count = 1 Then

    Set A = Application.Intersect(Range(Target.Address), Range("G4:Z2500"))
    If Not A Is Nothing Then
    Call macro
    Else: Call DeleteAllShapes
    End If

End If
把这个放在开头

if target.column=7 or target.column=17 or target.column=26 then exit sub

If not Intersect(Target, Range("G:G,Q:Q,Z:Z")) Is Nothing Then Exit Sub
'etc