å¦æä¸æ¢1,2å¢ï¼è¿æç´å°10çè¯æä¹åå¢
追ç'æ¯ä¸é¡¹éé¢æè¦æ±å¢å æ´å¤çelseif
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Comment Is Nothing Then
If Target.Value = 1 Then
Target.AddComment "A"
ElseIf Target.Value = 2 Then
Target.AddComment "B"
ElseIf Target.Value = 3 Then
Target.AddComment "C"
ElseIf Target.Value = 4 Then
Target.AddComment "D"
ElseIf Target.Value = 5 Then
Target.AddComment "E"
ElseIf Target.Value = 6 Then
Target.AddComment "F"
ElseIf Target.Value = 7 Then
Target.AddComment "G"
ElseIf Target.Value = 8 Then
Target.AddComment "H"
ElseIf Target.Value = 9 Then
Target.AddComment "I"
ElseIf Target.Value = 10 Then
Target.AddComment "J"
End If
Else
If Target.Value = 1 Then
Target.Comment.Text "A"
ElseIf Target.Value = 2 Then
Target.Comment.Text "B"
ElseIf Target.Value = 3 Then
Target.Comment.Text "C"
ElseIf Target.Value = 4 Then
Target.Comment.Text "D"
ElseIf Target.Value = 5 Then
Target.Comment.Text "E"
ElseIf Target.Value = 6 Then
Target.Comment.Text "F"
ElseIf Target.Value = 7 Then
Target.Comment.Text "G"
ElseIf Target.Value = 8 Then
Target.Comment.Text "H"
ElseIf Target.Value = 9 Then
Target.Comment.Text "I"
ElseIf Target.Value = 10 Then
Target.Comment.Text "J"
End If
End If
End Sub
=========================================================================
打开Excel,按ALT+F11,双击左边的sheet1,输入以下代码:
Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("A1:D100")) Is Nothing Then Exit Sub
If Target.Count > 1 Then Exit Sub
If Target.Value = "1" Then
Target.Comment.Delete
Target.AddComment.Text Text:="内容是1"
ElseIf Target.Value = "2" Then
Target.Comment.Delete
Target.AddComment.Text Text:="内容是2"
End If
End Sub
如下图(点击可放大)
本回答被网友采纳