View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Steve E Steve E is offline
external usenet poster
 
Posts: 62
Default Macro to clear range contents when cell contents are changed b

Steve;

Works just like I'd hoped!

Next question: this clears the formatting too (I have the borders formatted
so that they print... any way to leave the formatting alone and just clear
the range contents?

Thanks!

"stevebriz" wrote:


give this a try and see if it does what you want.

Put this code in the worksheet module of the sheet you are trying to
use.
If you have any questions let me know.

--------------------------------------------------------------------------------------------

Private Sub Worksheet_Change(ByVal Target As Range)
Dim Rchange As Integer
Rchange = Target.Row ' row number selected
If Rchange 17 And Rchange < 35 Then ' make sure only applies to
rows 18 to 34
If Target.Address = "$D" & "$" & Rchange Then
'MsgBox "Target address changed :" & Target.Address
Range("L" & Rchange, "T" & Rchange).Clear ' clears cells
for in this row for cols L to T
MsgBox "Range: " & " L" & Rchange & " to " & " T" &
Rchange & " Cleared" ' optional
End If
Else
End If
End Sub