View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default How to run macro automatically from range of cells

First, you wouldn't use the worksheet_selection change event.

Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
'one cell at a time!
If Target.Cells.Count 1 Then Exit Sub
If Intersect(Target, Me.Range("a:a")) Is Nothing Then
Exit Sub
End If

If UCase(Target.Value) = UCase("PAID") Then
Call OpenCalendar
End If
End Sub

Kevin wrote:

Hi,
I'm trying to run a macro automatically as soon as I enter specific text in
any cell of column A.

I have managed to run following code which works fine but it activates
macro as soon as I click cell in column A.

But I like to activate macro only if I add text "PAID" in any cell of column
A. Could someone please help. Here's the code:

Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
If Not Intersect(Target, Range("A1:A3000")) Is Nothing Then
Call OpenCalendar
End If
End Sub

Thanks in advance
Kevin


--

Dave Peterson