|
- 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
- End With
- End If
- End If
- End Sub
复制代码 |
|