2017-08-07 58 views
0

我在纸张1和纸张2上工作,并且在两张纸中都有包含代码的形状。表单1中的形状ID为“RUN 1”,表单2中为“EQ-1”。我已经有一个代码可以识别我在sheet1/sheet2上点击过的形状ID。但是代码调试的解释是“找不到具有指定名称的项目”。谢谢。请帮助:) 此代码必须位于板材2从另一张纸上识别单击形状的名称

sub x() 

'the first trial 
If Sheet1.Shapes(Application.Caller).Name = "RUN 1" Then Sheet2.Cells(1, 2) = "x" 
If activesheet.Shapes(Application.Caller).Name = "EQ-1" Then Sheet2.Cells(1, 2) = "x" 

'the second trial 
If Sheet1.Shapes(Application.Caller).Name = "RUN 1" Or _ 
activesheet.Shapes(Application.Caller).Name = "EQ-1" Then Sheet2.Cells(1, 2) = "x" 

end sub 

回答

0

尝试...

Sub x() 

    If Application.Caller = "RUN 1" Or Application.Caller = "EQ-1" Then 
     Sheet2.Cells(1, 2) = "x" 
    End If 

End Sub 

希望这有助于!

相关问题