Excel精英培训网

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

[已解决]请老师给我编个学生每年升一个年级的vba.

[复制链接]
发表于 2012-1-3 20:18 | 显示全部楼层 |阅读模式
9学分
教育上每年要统计学生情况,过1年学生所读年级就升1级,能不能请老师给我编一个vba全部一起升级。b列6年级要在c列中升成初中1年级,初中3年级可以升成初中4年级(升好后再调整)


A
B
C
姓名
小学何年级
初中何年级
xxx
2
 
xxx
 
3
xxx
5
 
xxx
 
2
xxx
 
1
xxx
4
 
xxx
3
 
xxx
6
 

最佳答案
2012-1-3 20:46
Sub test()
    Dim i&
    For i = 3 To [a65536].End(xlUp).Row
        If Cells(i, 2) <> "" Then
            If Cells(i, 2) > 5 Then
                Cells(i, 2) = ""
                Cells(i, 3) = 0
            Else
                Cells(i, 2) = Cells(i, 2) + 1
            End If
        End If
        If Cells(i, 3) <> "" Then Cells(i, 3) = Cells(i, 3) + 1
    Next
End Sub

发表于 2012-1-3 20:46 | 显示全部楼层    本楼为最佳答案   
Sub test()
    Dim i&
    For i = 3 To [a65536].End(xlUp).Row
        If Cells(i, 2) <> "" Then
            If Cells(i, 2) > 5 Then
                Cells(i, 2) = ""
                Cells(i, 3) = 0
            Else
                Cells(i, 2) = Cells(i, 2) + 1
            End If
        End If
        If Cells(i, 3) <> "" Then Cells(i, 3) = Cells(i, 3) + 1
    Next
End Sub
回复

使用道具 举报

 楼主| 发表于 2012-1-3 21:24 | 显示全部楼层
在屋内都能感觉到夜空是那么美啊!
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-5-4 02:42 , Processed in 0.141629 second(s), 10 queries , Gzip On, Yac On.

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

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