I try to implement a feature that automatically creates a comment attached to a cell, if a certain letter was typed into this cell by a user. The switch-case statement works fine as long as I don't use autocompletion, e.g. I type in an "A" and want to fill it into the next cells by dragging the green frame towards those cells. Then I immediately receive a runtime error 13: mismatched types.
To counter this I tried to add a foreach-loop.
Private Sub Worksheet_Change(ByVal Target As Range)
Dim cell As Variant
For Each cell In Target
Application.EnableEvents = False
Select Case Target.Cells
Case Is = "A": Target.AddComment ("text: ")
Case Is = "B": Target.AddComment ("text: ")
Case Is = "C": Target.AddComment ("text: ")
Case Is = "D": Target.AddComment ("text: ")
Case Is = "E": Target.AddComment ("text: ")
Case Is = "F": Target.AddComment ("text : ")
End Select
Application.EnableEvents = True
Next cell
On Error Resume Next
End Sub
However, the error still appears.