AmeliaBedelia
New Member
- Joined
- Apr 8, 2018
- Messages
- 19
I found Worksheet_Change code that works like a charm for one row, but I want to be able to duplicate or run the code for multiples rows. What this code does is pops up a warning message stating "Only one entry allowed." and will not allow the user to enter in another entry until they clear out the previous entry in that same row. For example there are 5 rows of questions (F13:F17). In column G through I the user is able to select an 'x' from a data validation drop down list. I want this pop up to display if they try to select two 'x' in the same row. So for row 13 they select a response (x) in either G13, H13 or I13. The code below only allows them to select one 'x' in either G13, H13 or I13 and when they try to select a second option in these three cells it pops up the warning message.
I want to duplicate this code so that this happens in row 14-17. Each row is a separate question and needs to stand alone.
Private Sub Worksheet_Change(ByVal Target As Range)
Dim rLook As Range
Set rLook = Range("G13:I13")
Dim wf As WorksheetFunction
Set wf = Application.WorksheetFunction
If Intersect(Target, rLook) Is Nothing Then Exit Sub
If wf.CountA(rLook) < 2 Then Exit Sub
Application.EnableEvents = False
Target.ClearContents
MsgBox "Only one entry allowed"
Application.EnableEvents = True
End Sub
Hopefully I explained it well enough.
Thanks
I want to duplicate this code so that this happens in row 14-17. Each row is a separate question and needs to stand alone.
Private Sub Worksheet_Change(ByVal Target As Range)
Dim rLook As Range
Set rLook = Range("G13:I13")
Dim wf As WorksheetFunction
Set wf = Application.WorksheetFunction
If Intersect(Target, rLook) Is Nothing Then Exit Sub
If wf.CountA(rLook) < 2 Then Exit Sub
Application.EnableEvents = False
Target.ClearContents
MsgBox "Only one entry allowed"
Application.EnableEvents = True
End Sub
Hopefully I explained it well enough.
Thanks