In the worksheet Class module, and very simplistically...
Private Sub Worksheet_Change(ByVal Target As Range)
Dim lngCol As Long
Dim lngCell As Long
Dim c As Excel.Range
On Error GoTo Catch
Const MinCol As Long = 61
Const MaxCol As Long = 71
If Target.Areas.Count > 1 Then
MsgBox "Cannot process non-contiguous ranges...", vbExclamation, "Error"
Exit Sub
Else
Application.EnableEvents = False
End If
'// Work from Last Cell to first...
For lngCell = Target.Cells.Count To 1 Step -1
Set c = Target.Cells(lngCell)
If c.Value = vbNullString And c.Column >= MinCol And c.Column <= MaxCol Then
For lngCol = 0 To (MaxCol - 1) - c.Column
c.Offset(, lngCol).Value = c.Offset(, lngCol + 1).Value
Next
'// Something was deleted, the LAST cell, at least, must be blank
c.Offset(, MaxCol - c.Column).Value = vbNullString
End If
Next
Catch:
'// not interested in errors - just turn on Event handling
Application.EnableEvents = True
End Sub
Changed to work with multiple cells, but not multiple areas. The selection must be contiguous...
Bookmarks