View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
Mallick Mallick is offline
external usenet poster
 
Posts: 17
Default Running a Macro when a value in a range of cell changes

Hi Steve

Thanks for your help. It solves the problem that I put in my question.
However, there is still a catch.

If i manually change my values in "myRange", it performs perfectly. However,
my real issue was that "myRange" actually consists of decision variables of
an optimization problem. I am using Pallisade Add-In called Evolver. Evolver
changes the decision variables in each iteration and I want my macro to run
each time the decision variable changes.

Do you have any solution to this problem.

Many thanks.

Mallick
"AltaEgo" wrote:

Hi Mallick

The following should do the trick.

1) Right click the tab of the relevant worksheet
2) Click "View Code"
3) Paste
4) You also need to specify the range of cells where the code should
activate. The easiest way to do this is to use a named range. In the sample
below, I named my cells myRange.


Private Sub Worksheet_Change(ByVal Target As Range)

Set isect = Application.Intersect(Target, Range("myRange"))
If Not isect Is Nothing Then
'replace the next line with your code
' or call your macro
MsgBox Target
msgbox Target.address

End If

End Sub




--
Steve

"Mallick" wrote in message
...
Hi
I am trying to run my macro whenever there is change of values in a range
of
cells. For example, A table of 4x4 contains all zeros initially, I want
the
macro to run whenever the initial value in any cell changes.

Can anyone help me with this?

Many Thanks.

Mallick