Edit a macro with another macro?

JB27

New Member
Joined
Oct 2, 2009
Messages
41
Hello,
Does anyone know if it is possible to edit one macro, with another macro?

I have the following code in Sheet1

Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("AB:AB")) Is Nothing Then Exit Sub
Module2.RunSnippet1
End Sub

So everytime I edit column AB on Sheet1, it will run my code. There is another bit of code that I use however to clear Sheet1 (we'll just call it "Module3.Clear") and re-import data, which in turn changes column AB and then that triggers the code I posted above, which just hoses everything. Is there some way I can essentially turn off my Private Sub code when I run Module3.Clear and then turn it back on at the end of Module3.Clear?

I guess I'm wondering if it's possible to edit a macro, with another macro, so I could just add an apostrophy in front of it and the begging of Module3.Clear and then remove it at the end. Any thoughts and suggestions are welcome.
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
Put this at the beginning of your code (before calling RunSnippet1):

Application.EnableEvents = False

and set it back to True at the end.
 
Upvote 0

Forum statistics

Threads
1,224,504
Messages
6,179,142
Members
452,892
Latest member
JUSTOUTOFMYREACH

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