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

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
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
 
Upvote 0
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.
 
Upvote 0

Forum statistics

Threads
1,214,653
Messages
6,120,755
Members
448,989
Latest member
mariah3

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