ExcelHome技术论坛

 找回密码
 免费注册

QQ登录

只需一步,快速开始

快捷登录

搜索
EH技术汇-专业的职场技能充电站 妙哉!函数段子手趣味讲函数 Excel服务器-会Excel,做管理系统 Excel Home精品图文教程库
HR薪酬管理数字化实战 Excel 2021函数公式学习大典 Excel数据透视表实战秘技 打造核心竞争力的职场宝典
300集Office 2010微视频教程 数据工作者的案头书 免费直播课集锦 ExcelHome出品 - VBA代码宝免费下载
用ChatGPT与VBA一键搞定Excel WPS表格从入门到精通 Excel VBA经典代码实践指南
查看: 1376|回复: 6

[原创] 用宏自动完成成绩核算

[复制链接]

TA的精华主题

TA的得分主题

发表于 2010-7-4 22:01 | 显示全部楼层 |阅读模式
用宏自动完成多个学校多个学科的成绩核算,辛辛苦苦好多天,终于完成了!
宏算成绩.rar (20.4 KB, 下载次数: 57)

TA的精华主题

TA的得分主题

发表于 2010-7-4 22:13 | 显示全部楼层
我怎么找不到宏?

TA的精华主题

TA的得分主题

 楼主| 发表于 2010-7-4 23:16 | 显示全部楼层
找不到?那我直接传代码
Sub 算成绩()
Dim xx(1 To 9) As String
Dim xxhz(1 To 9) As String
xx(1) = "南": xx(2) = "兴": xx(3) = "东": xx(4) = "西": xx(5) = "峪": xx(6) = "普": xx(7) = "尧": xx(8) = "苏": xx(9) = "后"
xxhz(1) = "南村": xxhz(2) = "兴中": xxhz(3) = "东风": xxhz(4) = "西沟": xxhz(5) = "峪头"
xxhz(6) = "普乐塬": xxhz(7) = "尧场": xxhz(8) = "苏家坡": xxhz(9) = "后沟"
m = InputBox("请输入年级如1、2、3")        '记录年级
If m < 5 Then
xxs = 9
Else
xxs = 7
End If
For q = 1 To xxs
  Sheets(xx(q)).Activate
  n = Application.WorksheetFunction.CountA(Range("A1: A50")) - 12          '记录考试人数
  '计算成绩
  l = Application.WorksheetFunction.Match("语文", Range("a2:e2"), 0)            '记录"语文"所在列数
  ywzf = Application.WorksheetFunction.Sum(Range(Cells(3, l), Cells(n + 2, l)))          '语文总分
  sxzf = Application.WorksheetFunction.Sum(Range(Cells(3, l + 1), Cells(n + 2, l + 1)))  '数学总分
  ywjg = Application.WorksheetFunction.CountIf(Range(Cells(3, l), Cells(n + 2, l)), ">59") '语文及格人数
  sxjg = Application.WorksheetFunction.CountIf(Range(Cells(3, l + 1), Cells(n + 2, l + 1)), ">59") '数学及格人数
  ywyx = Application.WorksheetFunction.CountIf(Range(Cells(3, l), Cells(n + 2, l)), ">79") '语文优秀人数
  sxyx = Application.WorksheetFunction.CountIf(Range(Cells(3, l + 1), Cells(n + 2, l + 1)), ">79") '数学优秀人数
  If m > 2 Then
  yyzf = Application.WorksheetFunction.Sum(Range(Cells(3, l + 2), Cells(n + 2, l + 2))) '英语总分
  yyjg = Application.WorksheetFunction.CountIf(Range(Cells(3, l + 2), Cells(n + 2, l + 2)), ">59") '英语及格人数
  yyyx = Application.WorksheetFunction.CountIf(Range(Cells(3, l + 2), Cells(n + 2, l + 2)), ">79") '英语优秀人数
  End If
  '输出成绩
  Cells(n + 3, l) = ywzf: Cells(n + 3, l + 1) = sxzf                      '语文、数学总分
  Cells(n + 4, l) = Round(ywzf / n, 2)                                    '语文、数学均分
  Cells(n + 4, l + 1) = Round(sxzf / n, 2)
  Cells(n + 5, l) = Round(Cells(n + 4, l) * 0.6, 2)                       '语文、数学均分折分
  Cells(n + 5, l + 1) = Round(Cells(n + 4, l + 1) * 0.6, 2)
  Cells(n + 6, l) = ywjg: Cells(n + 6, l + 1) = sxjg                       '语文、数学及格人数
  Cells(n + 7, l) = Round(ywjg / n * 100, 2)                               '语文、数学及格率
  Cells(n + 7, l + 1) = Round(sxjg / n * 100, 2)
  Cells(n + 8, l) = Round(Cells(n + 7, l) * 0.25, 2)                        '语文、数学及格率折分
  Cells(n + 8, l + 1) = Round(Cells(n + 7, l + 1) * 0.25, 2)
  Cells(n + 9, l) = ywyx: Cells(n + 9, l + 1) = sxyx                        '语文、数学优秀人数
  Cells(n + 10, l) = Round(ywyx / n * 100, 2)                                '语文、数学优秀率
  Cells(n + 10, l + 1) = Round(sxyx / n * 100, 2)
  Cells(n + 11, l) = Round(Cells(n + 10, l) * 0.15, 2)                       '语文、数学优秀率折分
  Cells(n + 11, l + 1) = Round(Cells(n + 10, l + 1) * 0.15, 2)
  Cells(n + 12, l) = Cells(n + 5, l) + Cells(n + 8, l) + Cells(n + 11, l)                       '语文、数学积分
  Cells(n + 12, l + 1) = Cells(n + 5, l + 1) + Cells(n + 8, l + 1) + Cells(n + 11, l + 1)
  If m > 2 Then                                     '英语科
  Cells(n + 3, l + 2) = yyzf
  Cells(n + 4, l + 2) = Round(yyzf / n, 2)
  Cells(n + 5, l + 2) = Round(Cells(n + 4, l + 2) * 0.6, 2)
  Cells(n + 6, l + 2) = yyjg
  Cells(n + 7, l + 2) = Round(yyjg / n * 100, 2)
  Cells(n + 8, l + 2) = Round(Cells(n + 7, l + 2) * 0.25, 2)
  Cells(n + 9, l + 2) = yyyx
  Cells(n + 10, l + 2) = Round(yyyx / n * 100, 2)
  Cells(n + 11, l + 2) = Round(Cells(n + 10, l + 2) * 0.15, 2)
  Cells(n + 12, l + 2) = Cells(n + 5, l + 2) + Cells(n + 8, l + 2) + Cells(n + 11, l + 2)
  End If
  '计算个人总分,统计合格人数
  hg = 0
  For i = 3 To n + 2
  If m < 3 Then
  Cells(i, l + 2) = Round(Cells(i, l) + Cells(i, l + 1), 0)
  If Cells(i, l) > 59 And Cells(i, l + 1) > 59 Then hg = hg + 1
  Else
  Cells(i, l + 3) = Round(Cells(i, l) + Cells(i, l + 1) + Cells(i, l + 2), 0)
  If Cells(i, l) > 59 And Cells(i, l + 1) > 59 And Cells(i, l + 2) > 59 Then hg = hg + 1
  End If
  Next i
  If m < 3 Then
  Cells(n + 6, l + 2) = hg
  Else
  Cells(n + 6, l + 3) = hg
  End If
Next q
End Sub

TA的精华主题

TA的得分主题

 楼主| 发表于 2010-7-4 23:19 | 显示全部楼层
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件       ★免费下载 ★       ★ 使用帮助
一至四年级的学校是九个学校,一至六年级的是九个学校。
英语是从三年级开始。

TA的精华主题

TA的得分主题

 楼主| 发表于 2010-7-4 23:20 | 显示全部楼层
错了,一至六年级都有的学校是前七个学校!

TA的精华主题

TA的得分主题

 楼主| 发表于 2010-7-4 23:27 | 显示全部楼层
另,有一问题:要统计合格人数1、如果是一、二年级,就是计算语文、数学两个学科都及格的人数;2、如果是三、四、五、六年级,就是计算语文、数学、英语三个学科都及格的人数。以前我都是用函数做的,计算合格人数用的是{=SUM(($B$3:B29>=60)*($C$3:C29>=60)*($D$3:D29>=60))}!问题是,数组公式在vba中怎么调用啊?

TA的精华主题

TA的得分主题

 楼主| 发表于 2010-7-4 23:30 | 显示全部楼层
哦,找到了,用Application.WorksheetFunction.FormulaArray = "=SUM(IF((B2:B1291=L3)*(E2:E1291=M3),G2:G1291))"这种方法。嗯!好, 我再改改!
您需要登录后才可以回帖 登录 | 免费注册

本版积分规则

关闭

最新热点上一条 /1 下一条

手机版|关于我们|联系我们|ExcelHome

GMT+8, 2024-6-17 12:18 , Processed in 0.045908 second(s), 11 queries , Gzip On, MemCache On.

Powered by Discuz! X3.4

© 1999-2023 Wooffice Inc.

沪公网安备 31011702000001号 沪ICP备11019229号-2

本论坛言论纯属发表者个人意见,任何违反国家相关法律的言论,本站将协助国家相关部门追究发言者责任!     本站特聘法律顾问:李志群律师

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