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?
 

Some videos you may like

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.

Peter_SSs

MrExcel MVP, Moderator
Joined
May 28, 2005
Messages
46,837
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?
 

Watch MrExcel Video

Forum statistics

Threads
1,113,953
Messages
5,545,153
Members
410,666
Latest member
forzasec
Top