0

I am trying to create a subroutine that runs when any cell in column 13 is changed. I've read a number of stack overflow questions already, but have not found my answer. here are some I've read:

Not activated by a change

Uses intersect. Doesn't address my issue

Might work but I'm not very good with events

I tried to make it work using the intersect fuction

Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)

If Not Intersect (Target, Activesheet.Columns(13)) Is Nothing Then
    MsgBox "Help Help"
EndIf

End Sub

This works when I change values but if left alone for a while it will come up with "Run-time error '1004': Method 'intersect of object '_Global' failed". Any ideas welcome. if there is a simpler way to acheive this, I'd love to know. Thank you for your time.

Community
  • 1
  • 1
NYoung
  • 157
  • 1
  • 14

1 Answers1

1

to handle ALL worksheet, place this in ThisWorkbook code pane

Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)

If Not Intersect(Target, Sh.Columns(13)) Is Nothing Then
    MsgBox "Help Help"
End If

End Sub

or

Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)

If Target.Column = 13 Then
    MsgBox "Help Help"
End If

End Sub

Otherwise place the following in the code pane of the Sheet(s) you want to "handle" only

Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Column = 13 Then
    MsgBox "Help Help"
End If

End Sub
user3598756
  • 28,893
  • 4
  • 18
  • 28