Running a auto macro

scooby103

New Member
Joined
May 22, 2003
Messages
32
Alright guys;
Is there a way to have a macro run when info is put into a certain cell? I have a column of cells that when something is put into any of those cells I want a macro to auto run instead of hitting a button to run the macro.

Thanks for your help.

A.
 

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.

nisht

Active Member
Joined
Feb 27, 2002
Messages
304
You can use worksheet change event to call the procedure.

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim unionrange As Range
'
' YOu can have your range define here..
Set unionrange = Union([b4:k12], [f7:l20])

If Not Intersect(Target, unionrange) Is Nothing Then
''Exit Sub
'
'Selection.Interior.ColorIndex = Int(Rnd(3) * 10) + 20
' you can call your procedure here
myprocedure

'
End If

Set unionrange = Nothing
End Sub
 

jimboy

Well-known Member
Joined
Apr 11, 2002
Messages
2,314
Yes. If you right mouse over the sheet name (i.e. Sheet1) and select view code then in left drop down box (top) select Worksheet and in the right box select Change, enter either your code or call another macro, like this;

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
'will exit if more than one cell is selected
If Target.Count > 1 Then Exit Sub

'will exit if any other column (except A) is amended
If Target.Column <> 1 Then Exit Sub

'calls your macro
Macro1

End Sub

Post back for more help.
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,152,095
Messages
5,768,054
Members
425,451
Latest member
JohnBrooksBiddle

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