VBA to seal cell, complete

Asked

Viewed 32 times

0

Good evening, I am preparing a VBA record sheet and I would like it, when selecting a specific cell, to be filled with an X and delete the other possible alternatives ...

If possible, I would like to delete some lines if selection is made

I tried the following formula, but without success:

Private Sub Worksheet_Change(ByVal Target As Range)

Application.EnableEvents = True

If Range(“U23”).Select Then
Range(“U23”) = "(X)"
Range(“Z23”) = "( )"
Range(“AE23”) = "( )"
End If

End Sub

1 answer

0

If it needs to be in the selection, you need to change:

Private Sub Worksheet_Change(Byval Target As Range) to Private Sub Worksheet_Selectionchange(Byval Target As Range)

And probably the code below will suit you better:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

Application.EnableEvents = False

Rows(Target.row).clear
Target.value = "(X)"

Application.EnableEvents = true

End Sub

Browser other questions tagged

You are not signed in. Login or sign up in order to post.