I have a macro assigned to a cell that executes once clicked on. The macro involves SAP scripting, which if ever interrupted (via CTRL+DEL+ALT), also causes my previously clickable cell to stop working.

I can run the macro via Developer yet the cell is not working. Note that the code provided below is pasted in the sheet where the clickable cell is, not in 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

Any ideas what might be causing the issue?

2 Answers

0
QuickSilver On

You need to close all if statements.

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
0
Error 1004 On

You could use:

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