auto run a macro when a column range is changed i.e. J12:J33

skyhi

New Member
Joined
Sep 24, 2006
Messages
13
I have set up a macro to run off a VB button but I would prefer to have it run when a number is added to the specific column range like B14:B90

Is it possible to make my macro runn automatically?
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).

Peter_SSs

MrExcel MVP, Moderator
Joined
May 28, 2005
Messages
50,700
Office Version
  1. 365
Platform
  1. Windows
skyhi

Welcome to the Mr Excel board!

Yes, this is possible. Right click the relevant sheet tab and choose 'View Code'. Paste this code and include your macro code where indicated. Post back with more details if this is not what you want.

<font face=Courier New><SPAN style="color:#00007F">Private</SPAN> <SPAN style="color:#00007F">Sub</SPAN> Worksheet_Change(<SPAN style="color:#00007F">ByVal</SPAN> Target <SPAN style="color:#00007F">As</SPAN> Range)
    <SPAN style="color:#00007F">If</SPAN> Target.Count <> 1 <SPAN style="color:#00007F">Then</SPAN> <SPAN style="color:#00007F">Exit</SPAN> <SPAN style="color:#00007F">Sub</SPAN>
    <SPAN style="color:#00007F">If</SPAN> Intersect(Target, Range("B14:B90")) <SPAN style="color:#00007F">Is</SPAN> <SPAN style="color:#00007F">Nothing</SPAN> <SPAN style="color:#00007F">Then</SPAN> <SPAN style="color:#00007F">Exit</SPAN> <SPAN style="color:#00007F">Sub</SPAN>
    
    <SPAN style="color:#007F00">'Your Macro code here</SPAN>
    
<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN></FONT>
 

skyhi

New Member
Joined
Sep 24, 2006
Messages
13
Peter_SSs,

Thanks so much.

Worked a treat.

Can you please tell me, if you know, if it is possible to protect a worksheet and still let the macros run?
 

skyhi

New Member
Joined
Sep 24, 2006
Messages
13
Small change to the question above

Is it possible up run a macro after a table have automatically update by importing data from a web query?
 

Forum statistics

Threads
1,141,931
Messages
5,709,406
Members
421,635
Latest member
mehdi hannechi

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