|
- Private Sub Worksheet_SelectionChange(ByVal Target As Range)
- If Target.Cells.Count = 1 Then
- If Target.Value <> "" Then
- Me.UsedRange.ClearComments
- Dim selectedValue As String
- selectedValue = Target.Value
- Set sht = ThisWorkbook.Sheets("锟斤拷锟斤拷锟斤拷息锟斤拷锟斤拷")
- arr = sht.UsedRange
- r = UBound(arr)
- rr = sht.Cells(Rows.Count, "h").End(3).Row
- brr = sht.Range(sht.[h1], sht.Cells(rr, "i"))
- crr = sht.Range(sht.[c1], sht.Cells(r, "c"))
- j = Application.Match(selectedValue, crr, 0)
- If IsError(j) Then Exit Sub
- If arr(j, 5) <> "" Then
- For i = 1 To Len(arr(j, 5))
- m = Val(Mid(arr(j, 5), i, 1))
- s = s & "锟斤拷" & Application.VLookup(m, brr, 2, 0)
- Next
- End If
- If arr(j, 6) <> "" Then
- For i = 1 To Len(arr(j, 6))
- m = Val(Mid(arr(j, 6), i, 1))
- ss = ss & "锟斤拷" & Application.VLookup(m, brr, 2, 0)
- Next
- End If
- If s <> "" Then s = "锟截监考锟斤拷目: " & Right(s, Len(s) - 1) & vbCrLf
- If ss <> "" Then ss = "锟斤拷锟截监考锟斤拷目: " & Right(ss, Len(ss) - 1)
- With Target
- ' If Not .Comment Is Nothing Then .Comment.Delete
- .AddComment Text:="锟洁考锟斤拷锟斤拷: " & arr(j, 4) & vbCrLf & s & ss
- .Comment.Visible = True
- .Comment.Shape.TextFrame.AutoSize = True
- End With
- Me.UsedRange.Cells.Interior.ColorIndex = xlNone
- Dim cel As Range
- For Each cel In Me.UsedRange
- If cel.Value = selectedValue Then
- cel.Interior.Color = RGB(0, 255, 0)
- End If
- Next cel
- End If
- End If
- End Sub
复制代码 |
|