I am trying to perform the simple task of having a cell A’s value change depending on whether the user clicked cell B, C, or D. For some reason, the code below only works for the first with statement (in chis case, the one that would set cell A’s value to “Low”). Does anyone know why it doesnt work when I click B or C? Any help with this code would be great! Thank you!
Sub Worksheet_SelectionChange(ByVal Target As Range)
With Target
If Not Intersect(.Cells, Columns(1)) Is Nothing Or .Count > 1 Then Exit Sub
Sheets("Sheet1").Range("A" & ActiveCell.row).Value = "Low"
If Not Intersect(.Cells, Columns(2)) Is Nothing Or .Count > 1 Then Exit Sub
Sheets("Sheet1").Range("A" & ActiveCell.row).Value = "Medium"
If Not Intersect(.Cells, Columns(3)) Is Nothing Or .Count > 1 Then Exit Sub
Sheets("Sheet1").Range("A" & ActiveCell.row).Value = "High"
End With
End Sub
your first statement will cause the routine to exit if it isn’t the first column. Change the tests around, and you will have a little more success
Also, as you are looking for specific columns, check them with a select case statement to make it less crowded