View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Gary''s Student Gary''s Student is offline
external usenet poster
 
Posts: 11,058
Default Clear contents on change

Try this:

Private Sub Worksheet_Change(ByVal Target As Range)
Set t = Target
Set rr = Union(Range("O:O"), Range("Q:Q"))
If Intersect(t, rr) Is Nothing Then Exit Sub
c = t.Column
r = t.Row
Application.EnableEvents = False
If c = 15 Then
Cells(r, "P").ClearContents
Cells(r, "Q").ClearContents
Cells(r, "R").ClearContents
Else
Cells(r, "P").ClearContents
Cells(r, "O").ClearContents
Cells(r, "R").ClearContents
End If
Application.EnableEvents = True
End Sub

--
Gary''s Student - gsnu200832


"Suzanne" wrote:

If a cell in COL O changes, I want to clear the contents of COL P, Q R (in
the same row)
If a cell in COL Q changes, I want to clear the contents of COL O, P, R
(again in the same row)

I think I had the following working in Excel 2003, but its not working in
2007.

Private Sub Worksheet_Change(ByVal Target As Excel.Range)

With Target
Select Case .Column
Case 15 'column O
Application.EnableEvents = False
Cells(.Row, "P").ClearContents
Cells(.Row, "Q").ClearContents
Cells(.Row, "R").ClearContents
Application.EnableEvents = True
Case 17 'column Q
Application.EnableEvents = False
Cells(.Row, "O").ClearContents
Cells(.Row, "P").ClearContents
Cells(.Row, "R").ClearContents
Application.EnableEvents = True
End Select
End With

End Sub