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

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).

Peter_SSs

MrExcel MVP, Moderator
Joined
May 28, 2005
Messages
56,596
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,176,423
Messages
5,903,037
Members
435,003
Latest member
farooquecool

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