Can it be done

colinharwood

Active Member
Joined
Jul 27, 2002
Messages
426
Office Version
  1. 2019
Platform
  1. Windows
Hi All

I have the following code on a worksheet,

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Cells.Count > 1 Then Exit Sub
If Target.Address > "$L " Then ActiveCell.Offset(rowOffset:=1, columnOffset:=-9).Activate

End Sub

Is it possible to cancel this code from a macro, so that the macro can run properly

Thanks a lot

Colin
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
You can disable events like this:

Application.EnableEvents = False

and enable them sfterwards like this:

Application.EnableEvents = True
 
Upvote 0
I'm not sure if what you are asking is possible, but there is another way around it:

1st, I assume that the macro is selecting a range.

Have the first line of the macro put a value (such as FALSE) into some obscure cell (or into some variable that is accessed by both the macro and the selectionchange routine.

In the first line of the selectionchange routine, put an If/Then statment that doesn't allow the body of the routine to run if the cell or variable value is as assigned by the first line of the macro.

In the last line of the macro, change the cell or variable value back (like to TRUE).

Hope that helps.
F.T.
 
Upvote 0

Forum statistics

Threads
1,213,482
Messages
6,113,913
Members
448,532
Latest member
9Kimo3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top