K
Kevin
hi
I was kindly given this code by Otto Moehrbach, which works,
However If i select a merged cell the sheet code crashes
the only way i can make the code active again is to close the workbook
and reopen it.
Can this code be adapted to deal with merged cells and is it posible
to restrict the number of rows
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count > 1 Then Exit Sub
If Target = "" Then Exit Sub
If Target.Column < 4 Or Target.Column > 6 Then Exit Sub
If Target.Column = 4 Then
Application.EnableEvents = False
Target.Offset(, 1).Resize(, 2).ClearContents
Application.EnableEvents = True
End If
If Target.Column = 6 Then
Application.EnableEvents = False
Target.Offset(, -2).Resize(, 2).ClearContents
Application.EnableEvents = True
End If
If Target.Column = 5 Then
Application.EnableEvents = False
Target.Offset(, -1).ClearContents
Target.Offset(, 1).ClearContents
Application.EnableEvents = True
End If
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Column < 4 Or Target.Column > 6 Then Exit Sub
Target = "X"
End Sub
thanks
kevin
I was kindly given this code by Otto Moehrbach, which works,
However If i select a merged cell the sheet code crashes
the only way i can make the code active again is to close the workbook
and reopen it.
Can this code be adapted to deal with merged cells and is it posible
to restrict the number of rows
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count > 1 Then Exit Sub
If Target = "" Then Exit Sub
If Target.Column < 4 Or Target.Column > 6 Then Exit Sub
If Target.Column = 4 Then
Application.EnableEvents = False
Target.Offset(, 1).Resize(, 2).ClearContents
Application.EnableEvents = True
End If
If Target.Column = 6 Then
Application.EnableEvents = False
Target.Offset(, -2).Resize(, 2).ClearContents
Application.EnableEvents = True
End If
If Target.Column = 5 Then
Application.EnableEvents = False
Target.Offset(, -1).ClearContents
Target.Offset(, 1).ClearContents
Application.EnableEvents = True
End If
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Column < 4 Or Target.Column > 6 Then Exit Sub
Target = "X"
End Sub
thanks
kevin