Excel精英培训网

 找回密码
 注册
数据透视表40+个常用小技巧,让你一次学会!
查看: 1470|回复: 1

[已解决]考号问题求教

[复制链接]
发表于 2012-12-7 12:41 | 显示全部楼层 |阅读模式
Book1.zip (17.06 KB, 下载次数: 12)
excel精英培训的微信平台,每天都会发送excel学习教程和资料。扫一扫明天就可以收到新教程
发表于 2012-12-7 14:49 | 显示全部楼层    本楼为最佳答案   
Sub 排考号()
    Dim i As Integer, k As Integer
    Range("A2:C416").Sort Key1:=Range("C2"), Order1:=xlDescending
    For i = 2 To 416
        If Range("a" & i) = Range("a" & i).Offset(-1, 0) Then
            k = 0
            Do While Range("a" & i + k) = Range("a" & i).Offset(-1, 0)
                k = k + 1
            Loop
            arr = Range("a" & i & ":c" & i)
            brr = Range("a" & i + k & ":c" & i + k)
            Range("a" & i & ":c" & i) = brr
            Range("a" & i + k & ":c" & i + k) = arr
        End If
        Range("d" & i) = Range("d" & i).Offset(-1, 0) + 1
    Next i
    Range("d1") = "考号"
End Sub
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|Archiver|Excel精英培训 ( 豫ICP备11015029号 )

GMT+8, 2024-5-20 00:18 , Processed in 0.644273 second(s), 10 queries , Gzip On, Yac On.

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表