我为宏分配了一个单元格,单击该单元格即可执行。该宏涉及SAP脚本编制,如果该脚本曾经被中断(通过CTRL + DEL + ALT),也将导致我之前可点击的单元格停止工作。
我可以通过Developer运行宏,但是该单元无法正常工作。请注意,下面提供的代码粘贴在可单击单元格所在的工作表中,而不是ThisWorkbook中。
Option Explicit
Private Sub Worksheet_SelectionChange(ByVal target As Range)
If Selection.CountLarge = 1 Then
If Not Intersect(target, Range("A10")) Is Nothing Then
Call FolderPicker
End If
End Sub
任何想法可能是导致问题的原因吗?
答案 0 :(得分:0)
您需要关闭所有if语句。
Option Explicit
Private Sub Worksheet_SelectionChange(ByVal target As Range)
If Selection.CountLarge = 1 Then
If Not Intersect(target, Range("A10")) Is Nothing Then
Call FolderPicker
End If
End If
End Sub
答案 1 :(得分:0)
您可以使用:
Option Explicit
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'Check count how many cells affected to avoid errors
If Target.Count = 1 Then
If Not Intersect(Target, Range("A10")) Is Nothing Then
Application.EnableEvents = False 'Disable events to avoid pointless code trigger
Call FolderPicker
Application.EnableEvents = True
End If
End If
End Sub