|
表头规范了一下:
- Private Sub Worksheet_Change(ByVal Target As Range)
- If Target.Count > 1 Then Exit Sub
- If Target.Row > 3 Then
- If Target.Column = 5 Or Target.Column = 7 Or Target.Column = 9 Or Target.Column = 11 Or Target.Column = 13 Then
- If Target.Value = "" Then
- Target.Offset(0, 1) = ""
- Else
- 体育项目 = Cells(2, Target.Column).Value
- 性别 = Cells(Target.Row, 4).Value
- 工作表名 = 性别 & "生评分标准"
- 成绩 = Target.Value
- With Sheets(工作表名)
- row_ = .[a1048576].End(3).Row
- col_ = .Cells(2, Columns.Count).End(1).Column
- ar = .Range(.[a1], .Cells(row_, col_))
- For j = 2 To UBound(ar, 2)
- If InStr(ar(2, j), 体育项目) > 0 Then
- 目标列 = j
- Exit For
- End If
- Next j
- For i = 3 To UBound(ar)
- If (InStr(ar(2, 目标列), "分") > 0 And Not InStr(ar(2, 目标列), "分钟")) > 0 Or InStr(ar(2, 目标列), "秒") > 0 Then
- If 成绩 <= ar(i, 目标列) Then
- Target.Offset(0, 1).Value = ar(i, 1)
- Exit For
- End If
- Else
- If 成绩 >= ar(i, 目标列) Then
- Target.Offset(0, 1).Value = ar(i, 1)
- Exit For
- End If
- End If
- If i = UBound(ar) Then Target.Offset(0, 1) = 0
- Next i
- End With
- End If
- End If
- End If
- End Sub
复制代码 |
|