Write macro that references another sheet?

Shack

New Member
Joined
Oct 26, 2005
Messages
6
[This post was split from this thread]

NateO said:
Hello Peter, change the target.address = "$c$2" to:

If Not Intersect(Target, [a1,c2,d3]) Is Nothing Then

Where a1 and d3 are precedents causing c2's calculated value to change.

I realize this thread has been dead for a couple of years, but I'm hoping you guys are still actively checking replies.....

This is my first macro, and I've followed all the responses in this thread so far, but how do you write a macro that references another worksheet?

my macro:

Sub Worksheet_Change(ByVal Target As Excel.Range)
On Error GoTo TheEnd
If Not Intersect(Target, [a2,c4,a3]) Is Nothing Then
MsgBox "I'm running"
Application.EnableEvents = False
Range("C7").GoalSeek Goal:=0.0001, ChangingCell:=Range("C16")
End If
TheEnd:
Application.EnableEvents = True
End Sub

What if the precedents (a2 and a3) are in another worksheet, within the same Excel file?


Thanks in advance,
Shack

Edited by Von Pookie
 
Jon, this works! I'm a noob at this, but I must have spent a couple of hours just trying to interpret the code you posted, and once I set everything in and adjusted it, it works.

Thanks a lot!
 
Upvote 0

Excel Facts

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

Forum statistics

Threads
1,220,965
Messages
6,157,119
Members
451,398
Latest member
rjsteward

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