View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Problem w/ worksheet change event

If they select the entire column, then .Row would not be between 11 and 312.
Nontheless, if you only want the changes made if a single cell has been
changed


'Lock/Unlock cells based on FT/PT status
On Error goto ErrHandler
if Target.count 1 then exit sub
If .Column = 5 And .Row 11 And .Row < 312 Then
Application.EnableEvents = False
If .Value = "PT" Then
Cells(.Row, 6).Value = 20
Else
Cells(.Row, 6).Value = 40
End If
End If

ErrHandler:
Application.EnableEvents = True


--
Regards,
Tom Ogilvy

"Steph" wrote in message
...
Hi all. I have the following inside a worksheet change event:
'Lock/Unlock cells based on FT/PT status
If .Column = 5 And .Row 11 And .Row < 312 Then
Application.EnableEvents = False
If .Value = "PT" Then
Cells(.Row, 6).Value = 20
Else
Cells(.Row, 6).Value = 40
End If
Application.EnableEvents = True
End If

I the user highlights and clears contents of column 5 and 6 at the same

time
(ie E5:F5), I get a type mismatch error on the line If .Value = "PT" Then,
and the change event won't fire unless I completely clode out of excel and
re-open. Any ideas on how to prevent that from happening?