|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
重复的排名会跳过下一个数,怎么改?如图
这是我的代码
- Private Sub Worksheet_Change(ByVal Target As Range)
- Dim ws As Worksheet
- Dim lastRow As Long
- Dim i As Long
-
- ' 指定工作表
- Set ws = ThisWorkbook.Sheets("成绩总览")
-
- ' 获取最后一行
- lastRow = ws.Cells(ws.Rows.Count, "C").End(xlUp).Row
-
- ' 检查是否发生在"C8:K"最后一行之间的更改
- If Not Intersect(Target, ws.Range("C8:K" & lastRow)) Is Nothing Then
- ' 循环每一行
- For i = 8 To lastRow
- ' 计算总分
- ws.Cells(i, "L").Value = Application.WorksheetFunction.Sum(ws.Range("C" & i & ":K" & i))
-
- ' 计算排名
- ws.Cells(i, "M").Formula = "=SUMPRODUCT((A$8:A$" & lastRow & "=A" & i & ")*(L$8:L$" & lastRow & ">L" & i & "))+1"
-
- ' 将排名公式结果复制为数值
- ws.Cells(i, "M").Value = ws.Cells(i, "M").Value
- Next i
- End If
- End Sub
复制代码
排名 .zip
(22.18 KB, 下载次数: 7)
|
|