Can it be done

colinharwood

Active Member
Joined
Jul 27, 2002
Messages
397
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

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.

Andrew Poulsom

MrExcel MVP
Joined
Jul 21, 2002
Messages
73,092
You can disable events like this:

Application.EnableEvents = False

and enable them sfterwards like this:

Application.EnableEvents = True
 

Fryer Tuck

Board Regular
Joined
Mar 20, 2002
Messages
64
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.
 

Forum statistics

Threads
1,144,274
Messages
5,723,442
Members
422,497
Latest member
dougy99

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
Top