




全文预览已结束
下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
Excel vba学生各班成绩分析统计及对应模板(修正版)访问_/file/id_84798498557394945.htm可下载相应模板及vba代码。各班成绩分析统计.xla vba代码(修正版)适合的学校计算方式为:在单科成绩按总分降序排列取前“N”(平均基数)名的基础上求单科平均及对全年级求年级平均,班名及年名在执行一下“清( )”后可自动显示出来,(注意:请修改一下暂坐生标志,防止先删了数据)模块2代码:Sub 清()清除“姓名”字段中含“N/A”的无效数据。清除“姓名”字段中含“a”的暂坐生。Dim i, j As Integeri = Range(A65536).End(xlUp).RowFor j = 1 To iIf IsError(Cells(j, 3) ThenRows(j).ClearContentsElseIf InStr(Cells(j, 3), a) 0 Then (”a”为暂坐生标志,模板中“A”为正确暂坐生标志,可自改)Rows(j).ClearContentsEnd IfNextEnd SubSub 统() ActiveCell.Formula = =sum(a1:f1)/ & i ActiveCell.FormulaR1C1 = =SUM(R-6C:R-1C)/ & i & Application.Run Book2.xls!Macro1 清除不必要数据 MsgBox 请先设好暂座标志 Application.Run 清 初始化 班级个数 平均基数 Dim i, m, j, n, o, jm, zh, li, newRange As Integer Dim i, m, j, n, o, newRange As Integer Dim tellMe As String On Error GoTo VeryEnd tellMe = 请输入一个平均基数 tellMe2 = 请输入一个正确的最大班级个数 i = Application.InputBox(prompt:=tellMe, Title:=平均基数, Default:=50, Type:=1) m = Application.InputBox(prompt:=tellMe2, Title:=班级个数, Default:=8, Type:=1) If i = False Then Exit Sub If m = False Then Exit SubVeryEnd: 求各班各科平均分 科目 Range(D2).Range(A1:I1).Select Selection.Copy Range(Q2).Select Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:= _ xlNone, SkipBlanks:=False, Transpose:=False Range(z2) = 政史 取得政史列号 For jm = 17 To 30 If Cells(2, jm) = 政治 Then zh = jm ElseIf Cells(2, jm) = 历史 Then li = jm End If Next 班级 j = 1 执行的班级个数 n = 83 执行的求平均 行号定位 o = 3 执行聚集 行号定位 While j = m Range(d & n & ).FormulaArray = =AVERAGE(LARGE(R-80C:R-1C,ROW(R1:R & i & ) Range(d & n & ).Select Selection.AutoFill Destination:=ActiveCell.Range(A1:I1), Type:= _ xlFillDefault ActiveCell.Range(A1:I1).Select Selection.Copy Range(q & o & ).Select Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:= _ xlNone, SkipBlanks:=False, Transpose:=False Range(z & o & ).Select On Error Resume Next ActiveCell.Formula = Cells(o, zh) + Cells(o, li) ActiveCell.FormulaR1C1 = =Application.WorksheetFunction.Sum(Chr( Asc(a) + zh- 1) & o , Chr(Asc(a) + li- 1) & o ) Chr (Asc(a) + li - 1) & 2 & : ActiveCell.FormulaR1C1 = Application.WorksheetFunction.Sum(Cells(o, zh), Cells(o, li) ActiveCell.FormulaR1C1 = =SUM(RC-3,RC-4) n = n + 81 j = j + 1 o = o + 1 Wend 求年平均分 Range(q & o & ).Select ActiveCell.FormulaR1C1 = =SUM(R- & m & C:R-1C)/ & m & Selection.AutoFill Destination:=ActiveCell.Range(A1:J1), Type:= _ xlFillDefault ActiveCell.Offset(0, -1).Range(A1).Select ActiveCell.FormulaR1C1 = 年平 设置格式为“2”位小数(红色) Range(Q3:Z12).Select Selection.NumberFormatLocal = 红色0.00_ ;红色-0.00 清空多余列 Dim jm As IntegerFor jm = 17 To 30 If Cells(2, jm) = 总分 Then Columns(jm).ClearContents ElseIf Cells(2, jm) = 年名 Then Columns(jm).ClearContents ElseIf Cells(2, jm) = 班名 Then Columns(jm).ClearContents End IfNext 清空无效数据 For Each c In Range(Range(A1), ActiveCell.SpecialCells(xlLastCell) If IsError(c) Then c.ClearContents End If Next c End SubThisbook代码:Private Sub Workbook_Open() Workbook_AddinInstall Add New CommandBar End SubPrivate Sub Workbook_AddinInstall() Dim CB As CommandBarControl Dim i As Integer i = 1 For Each CB In Application.CommandBars(1).Controls If CB.Caption = 成绩处理 Then 菜单已加入,则刪除 Application.CommandBars(Worksheet Menu Bar).Controls(成绩处理).Visible = True Application.CommandBars(Worksheet Menu Bar).Controls(成绩处理).Delete End If Next Dim objCmdBrPp As CommandBarPopup Set objCmdBrPp = Application.CommandBars.ActiveMenuBar.Controls.Add(Type:=msoControlPopup, Temporary:=False) On Error Resume Next objCmdBrPp.Caption = 成绩处理 Set objCmdBrPp = Nothing With Application.CommandBars(Worksheet menu bar).Controls(成绩处理) .Controls.Add(Type:=msoControlButton, Before:=1).Caption = 清 .Controls(清).OnAction = 清 End With With Application.CommandBars(Worksheet menu bar).Controls(成绩处理) .Controls.Add(Type:=msoControlButton, Before:=1).Caption = 统 .Controls(统).OnAction = 统 End With 建立工具栏 Dim xBar As CommandBar Dim xButton1 As CommandBarButton Dim xButton2 As CommandBarButton On Error Resume Next Application.CommandBars(CustomBar).Delete Set xBar = Application.CommandBars.Add(Name:=成绩处理, Position:=msoBarTop, MenuBar:=False, Temporary:=False) Set xButton1 = xBar.Controls.Add(Type:=msoControlButton) Set xButton2 = xBar.Controls.Add(Type:=msoControlButton) With xButton1 .Caption = 清 .Style = msoButtonCaption .OnAction = 清 End With With xButton2 .Caption = 统 .Style = msoButtonCaption .OnAction = 统 End With With Application.CommandBars(成绩处理) .Visible = True End With Set xBar = Nothing Set xButton1 = Nothing Set xButton2 = Nothing 固定工具栏 Dim intleft As Integer, introw As Integer intleft = Application.CommandBars(formatting).Width introw = Application.CommandBars(formatting).RowIndex Application.CommandBars(成绩处理).Left = intleft Application.CommandBars(成绩处理).RowIndex = introwEnd SubPrivate Sub Workbook_BeforeClose(Cancel As Boolean) 文件关闭,就刪除菜单 Dim CB As CommandBarControl On Error Resume Next For Each CB In Application.CommandBars(1).Controls If CB.Caption = 成绩处理 Then Applic
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 家纺陈列培训课件
- 口腔喷剂销售方案(3篇)
- 家乡的环境变化我的家乡作文(12篇)
- 业务合作意向协议函
- 智慧社区共享平台协议
- 项目沟通记录工具
- 改写扩写改写望洞庭350字14篇范文
- 质量控制与检测流程管理工具
- 最美的风景在追梦的路上550字11篇
- 2025年广东省广州市普通高中毕业班综合测试(二)语文试题及答案
- 充电桩应急知识培训总结课件
- 招商考试题库及答案
- 2025电梯安全管理员考试试题及答案
- 2025年购房合同协议标准版本
- 2025年事业单位笔试-海南-海南公共基础知识(医疗招聘)历年参考题库含答案解析(5卷套题【单项选择100题】)
- 江苏省苏州市九校决胜高考2025届高三下学期2月联考-语文试题(含答案)
- 老旧供水管网漏损治理项目可行性研究报告
- 铁路设备考试试题及答案
- 2025年高压电工考试题库:操作技能模拟训练题
- 工业设计中的美学与功能平衡
- 广东省东莞中学2025届英语八年级第二学期期末统考试题含答案
评论
0/150
提交评论