Can not get the 2nd part of the code below working. The code is intended to do two separate operations, 1st is prevent mutiple cell deletion, 2nd part is to jump to a specific cell when a certain cell is selected. This is to help improve navigation of the worksheet. So do 1st, and then do 2nd. Assistance appreciated.
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'The following
With Target
Dim rng As Range
If Not Intersect(Target, Range("A29:a58")) Is Nothing Then
If Selection.Cells.Count > 1 Then
Set rng = Selection
If Application.WorksheetFunction.CountA(rng) >= 1 Then
MsgBox "Cannot delete multiple cells - cancelling"
' Range("A29").Select
End If
End If
End If
Set rng = Nothing
End With
With Target
If Not Intersect(Target, Range("b29:b58")) Is Nothing Then
If Selection.Cells.Count > 1 Then
Set rng = Selection
If Application.WorksheetFunction.CountA(rng) >= 1 Then
MsgBox "Cannot delete multiple cells - cancelling"
' Range("A29").Select
End If
End If
End If
Set rng = Nothing
End With
'2nd Part of Code
If Target.Row = 17 And Target.Column = 2 Then
Range("b18").Select
End If
If Target.Row = 23 And Target.Column = 2 Then
Range("a29").Select
End If
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'The following
With Target
Dim rng As Range
If Not Intersect(Target, Range("A29:a58")) Is Nothing Then
If Selection.Cells.Count > 1 Then
Set rng = Selection
If Application.WorksheetFunction.CountA(rng) >= 1 Then
MsgBox "Cannot delete multiple cells - cancelling"
' Range("A29").Select
End If
End If
End If
Set rng = Nothing
End With
With Target
If Not Intersect(Target, Range("b29:b58")) Is Nothing Then
If Selection.Cells.Count > 1 Then
Set rng = Selection
If Application.WorksheetFunction.CountA(rng) >= 1 Then
MsgBox "Cannot delete multiple cells - cancelling"
' Range("A29").Select
End If
End If
End If
Set rng = Nothing
End With
'2nd Part of Code
If Target.Row = 17 And Target.Column = 2 Then
Range("b18").Select
End If
If Target.Row = 23 And Target.Column = 2 Then
Range("a29").Select
End If
End Sub