Hello, I'm setting a worksheet to score likert-scale (responses from 0-3, 1-5, etc.) questionnaires. I've been able to get code working to have one range of cells return the appropriate value when clicked (and 0 when clicked a second time), but haven't been able to get code for multiple columns to work. For example, for a worksheet that has three columns, one each for responses from 1-3, the code for the "1" column is:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim myTarget As Range
Dim NewVal As Single
Set myTarget = Range("D15:D34")
If Selection.Cells.Count = 1 Then
If Not Intersect(Target, myTarget) Is Nothing Then
Select Case Target.Value
Case 0: NewVal = 1
Case 1: NewVal = 0
Case Else: NewVal = Target.Value
End Select
Target.Value = NewVal
End If
End If
End Sub
This works as expected. I want to add two more target ranges: E15:E34 to return 2 when clicked, and F15:F34 to return 3 when clicked. I've tried a few variations of adding in lines of code for the second (E15:E34, returns "2" or 0), but none have worked thus far. I'm not sure where my syntax is going wrong. Any help is appreciated! (Eventually I want each row to have each row only allow one response, but one thing at a time.)
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim myTarget As Range
Dim NewVal As Single
Set myTarget = Range("D15:D34")
If Selection.Cells.Count = 1 Then
If Not Intersect(Target, myTarget) Is Nothing Then
Select Case Target.Value
Case 0: NewVal = 1
Case 1: NewVal = 0
Case Else: NewVal = Target.Value
End Select
Target.Value = NewVal
End If
End If
End Sub
This works as expected. I want to add two more target ranges: E15:E34 to return 2 when clicked, and F15:F34 to return 3 when clicked. I've tried a few variations of adding in lines of code for the second (E15:E34, returns "2" or 0), but none have worked thus far. I'm not sure where my syntax is going wrong. Any help is appreciated! (Eventually I want each row to have each row only allow one response, but one thing at a time.)