Hi all - new to VBA and trying to get this to work - any assistance is grateful.
I am looking to control data entry in one of two worksheet columns (14 and 16) -such that data entry will only be accepted in one column OR the other, but not both.
Ideally, the code should behave such that once text (from a drop down list) is selected in one column (14 or 16), nothing occurs (e.g.this is acceptable), however, once text is selected in BOTH columns (14 AND 16), the other cell is deleted and a message box is thrown indicating that one or the other can contain text, but not both.
Here is what I have so far:
However, this does not seem to work. Any ideas?
I am looking to control data entry in one of two worksheet columns (14 and 16) -such that data entry will only be accepted in one column OR the other, but not both.
Ideally, the code should behave such that once text (from a drop down list) is selected in one column (14 or 16), nothing occurs (e.g.this is acceptable), however, once text is selected in BOTH columns (14 AND 16), the other cell is deleted and a message box is thrown indicating that one or the other can contain text, but not both.
Here is what I have so far:
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim NoGo As Boolean
Select Case Target.Column
Case 1: If Target.Column = 14 And Target.Value <> "" Then NoGo = True
Case 2: If Target.Column = 16 And Target.Value <> "" Then NoGo = True
End Select
If NoGo Then
Application.EnableEvents = False
Target.ClearContents
Application.EnableEvents = True
MsgBox "Please choose a drive letter OR a mount point, not both.", vbExclamation
End If
End Sub