Activate macro when data is entered into a cell

RogerC

Well-known Member
Joined
Mar 25, 2002
Messages
536
I have a filter macro that I would like to run if a user enters any data into a certain range of cells. Does anyone know if it is possbile to have a macro execute when data (any data) has been entered into a range of cells? Thanks!
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
Yes, this is possible.

Say you want to run your macro if data is entered into range A1:D10

Right click the worksheet tab and click View Code. This will open the code module of that worksheet. Use code like this:-

<pre>
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Me.Range("A1:D10")) Is Nothing Then YourMacroName
End Sub
</pre>

The worksheet change event is one of Excel VBA's built in events. You can write code like that above to repond to user actions.
 
Upvote 0
Dan- thanks so much for your help. I tried using your code... substituting my data range and the name of my macro for YourMacroName, of course. When I enter data into my range I get a 'Compile Error - Ambiguous Name Detected: Worksheet_Change'. Can you tell me what to look for now? BTW, I'm using one other WorkSheet_Change Private Sub in the same worksheet and it works fine. Thanks!
 
Upvote 0
you can only have 1 worksheet_change event per worksheet. Stick the new code in the other one...

Paddy
 
Upvote 0

Forum statistics

Threads
1,213,527
Messages
6,114,144
Members
448,552
Latest member
WORKINGWITHNOLEADER

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