Delete Certain Code in Sheet

hajiali

Well-known Member
Joined
Sep 8, 2018
Messages
624
Office Version
  1. 2016
Platform
  1. Windows
I have many codes with in a worksheet. I would like to be able to Delete the following code with:

VBA Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    Const Rng = "B4:J100"
    If Not Intersect(Selection, Range(Rng)) Is Nothing Then
        Application.EnableEvents = False
        MsgBox "CHANGES CAN ONLY BE MADE ON EXPORTED FILE.", vbCritical, "ERROR"
        Range("I1").Activate
        Application.EnableEvents = True
    End If
End Sub

I found link to delete all VBA codes HERE. but I would like to just delete the above code from the sheet that way users are able to make changes in the Rng = "B4:J100" when file is exported.
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
press ALT -F11, to enter VBE
then press CTL-F (to find)
enter: Private Sub Worksheet_SelectionChange(ByVal Target As Range)

delete the block.
press F3 to find the next instance.
 
Upvote 0
Thank you Ranman I was wanting a VBA code that will do the deletion of the above code automatically.
 
Upvote 0

Forum statistics

Threads
1,214,827
Messages
6,121,823
Members
449,049
Latest member
cybersurfer5000

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