Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

ADJ Macro Worksheet Selection change event Hi, How could this worksheet change e

ID: 3565353 • Letter: A

Question

ADJ Macro Worksheet Selection change event

Hi,

How could this worksheet change event could include two macro, as each sheet must have one named as worksheet change event. The space after "Unload me" and "On error resume Next" between these two I tried using end if but that does not work.

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
On Error Resume Next
If Intersect(Target, Range("G3:G36")) Is Nothing Then Exit Sub
If Target.Cells.Count > 1 Then Exit Sub
UserForm1.Show
Unload Me


On Error Resume Next
If Intersect(Target, Range("J3:J36")) Is Nothing Then Exit Sub
If Target.Cells.Count > 1 Then Exit Sub
UserForm1.Show
Unload Me
End Sub

Thanks

Explanation / Answer

Unload Me is only valid in the module of a userform, not in a worksheet module.

You could use

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
On Error Resume Next
If Intersect(Target, Range("G3:G36,J3:J36")) Is Nothing Then Exit Sub
If Target.Cells.Count > 1 Then Exit Sub
UserForm1.Show
End Sub

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote