View Single Post
  #5   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

would a following simpler approach do the trick for me?

Private Sub WorkSheet_SelectionChange(ByVal Target As Range)
Call Main
End Sub

Many Thanks

Mallick
"Mallick" wrote:

Thanks smartin and AltaEgo for your quick replies.

AltaEgo, Your step wise answer was easy to implement but can you please
explain intersect method in general and what specific task it performs here.

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