View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Otto Moehrbach[_6_] Otto Moehrbach[_6_] is offline
external usenet poster
 
Posts: 201
Default Deleting/Changing values

The line:
..Offset(1).EntireRow.Insert xlShiftDown
inserts a row immediately below the Target row.
You say that you want to delete the row immediately below the target
row. Use:
..Offset(1).EntireRow.Delete

You also say you want the number of rows to remain constant. Obviously, you
cannot delete or insert a row and have the number of rows remain constant.
So I don't know what you want there.

You also say that you want this to happen if you clear or delete the
contents of a target cell. What you have will trigger the action if the
value of a target cell changes to anything, including blank. Add a line at
the beginning of the macro as:
If Target<"" Then Exit Sub. HTH Otto
"teresa" wrote in message
...
Hi,

Im trying to tweak the code so that if i delete/clear a value, the row
below
is deleted, thks a lots.
Also, currently If I change values a row is inserted, I would like it so
that
the no of rows remain.


Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
On Error GoTo ws_exit:
With Target
If .Column = 1 Then
If .Cells.Count = 1 Then
.Offset(1).EntireRow.Insert xlShiftDown
End If
End If
End With

ws_exit:
Application.EnableEvents = True
End Sub