I wrote a macro to change the value of a cell in the range B3:B17 from "y" to "" and from "" to "y" whenever it is selected. The macro works but when I select more than one cell, it fails.
Private Sub Worksheet_SelectionChange(ByVal_
Target As Excel.Range)
If Target.Column = 2 And Target.Row >= 3_
And Target.Row <= 17 Then
ThisRow = Target.Row
If Target.Value = "" Then
Target.Value = "y"
End
End If
If Target.Value = "y" Then
Target.Value = ""
End
End If
End If
End Sub
How can I improve the codes?
Private Sub Worksheet_SelectionChange(ByVal_
Target As Excel.Range)
If Target.Column = 2 And Target.Row >= 3_
And Target.Row <= 17 Then
ThisRow = Target.Row
If Target.Value = "" Then
Target.Value = "y"
End
End If
If Target.Value = "y" Then
Target.Value = ""
End
End If
End If
End Sub
How can I improve the codes?