View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Corey Corey is offline
external usenet poster
 
Posts: 172
Default how to prevent code running when in a worksheet code

thanks again for the reply.
My problem is that the macro I am trying to run, but needs to stop this
code,
simply selects the entire range (c8:r20) and clears the cells.

As there is no actual value to enter I am a little lost to entering this
into the code???

Corey....


"Carim" wrote in message
oups.com...
Hi Corey,

I think I did not express myself clearly enough ...
With a test of your own ...
say if there is the number 1 in cell A1 then nothing happens,
otherwise your macro is executed ...

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim MyRange As Range

If Range("A1").Value = 1 Then
Exit Sub
Else
If Not Intersect(Target, Range("C8:R30")) Is Nothing Then
Call frmCalendar.Show
End If
End If

End Sub

Hope this clarifies
Cheers
Carim