Auto Run Macros when cell range is changed

dosborn

New Member
Joined
Dec 21, 2011
Messages
12
I am looking for a way to run my macro automatically when a specific range of cells has any input change.

If cell range S11:S34 on Sheet1 has any changes I would like to run my PartBalance macro which affects Sheet2

I have tried using the following:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Address = "$S$11:$S$34" Then
Call PartBalance
End If
End Sub

I think I have something wrong because it will not run on it's own when the cell value changes. Please help. Thanks.
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
You need to use the Application.Intersect method..

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("$S$11:$S$34")) Is Nothing Then
    Exit Sub
Else
    Call PartBalance
End If
End Sub
 
Upvote 0
Thank you Jim, I tried the code; however, my macro is still not running automatically. Here are some more specifics I should have probably initially included.

I have two sheets:
Sheet1 ("PART REQUEST")
Sheet2 ("PART REQUISITION")

When an input is made onto Sheet1 cell D11 and K11 if there is a remaining balance in S11 the value entered in S11 needs to fill into Sheet2 cell C11.

Do I need to do the Application.Intersect method on Sheet 2 to make it work?

Thanks for the help.
 
Upvote 0

Forum statistics

Threads
1,216,100
Messages
6,128,825
Members
449,470
Latest member
Subhash Chand

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