Run Macro whenever this cell changes

roheba

New Member
Joined
Oct 22, 2010
Messages
12
When I run Macro1, in my worksheet, it performs a goal-seek process then stops. I want to repeat this macro one time whenever a change is made to Cell C14. I think this is a worksheet_change event. I have tried repeatedly, but unfortunately, my knowledge and skill-set are inadequate to write the VB code necessary to make this happen. Please help.
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
it is a worksheet change event, try and include the following in the sheet code

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$C$14" Then
Call Macro1
End If
End Sub

i hope this will solve your problem
 
Upvote 0
Thank you for your suggested solution.

It seems so simple, but... "try and include the following in the sheet code"

Please tell me where and how to add this to the worksheet.
 
Upvote 0
My active sheet is Sheet1.

Before I make the modifications indicated below, please accept that my Macro1 functions quite well.

In an effort to implement the suggested Worksheet_Change code, I went to the VB code page for Sheet1 and changed from (General) and Declarations to Worksheet and Change. Then I entered the above code.

Back on Sheet1, I changed the contents of Cell C14. I immediately receive a dialogue box indicating there is a VB runtime error "1004", Reference isn't valid. When I press the Debug button I'm shown Macro1 with the line defining the parameters for the GoalSeek highlighted in yellow.

This is the line of code that stops the process.: Range("C44").GoalSeek Goal:=0, ChangingCell:=Range("C29")

Apparently the GoalSeek process is incompatible with the Worksheet_Change code. Any suggestions?
 
Upvote 0
I am not sure what you have in Macro1.

Try running the Macro1 independently or you may execute the Macro step by step by press "F8" for each step and check where the problem is. Perhaps if the Macro1 runs perfectly, depending and executing the Macro1 each time on a value change in C14 should not be a problem.
 
Upvote 0

Forum statistics

Threads
1,223,888
Messages
6,175,207
Members
452,618
Latest member
Tam84

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