




下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
Excelvba学生各班成绩分析统计及对应模板(修正版)访问—/file/id_84798498557394945.htm可下载相应模板及vba代码。各班成绩分析统计.xlavba代码(修正版)适合的学校计算方式为:在单科成绩按总分降序排列取前“N”(平均基数)名的基础上求单科平均及对全年级求年级平均,班名及年名在执行一下“清()”后可自动显示出来,(注意:请修改一下暂坐生标志,防止先删了数据)模块2代码:Sub清()清除“姓名”字段中含“N/A”的无效数据。清除“姓名”字段中含“a”的暂坐生。Dimi,jAsIntegeri=Range("A65536").End(xlUp).RowForj=1ToiIfIsError(Cells(j,3))ThenRows(j).ClearContentsElseIfInStr(Cells(j,3),"a")>0Then'(”a”为暂坐生标志,模板中“A”为正确暂坐生标志,可自改)Rows(j).ClearContentsEndIfNextEndSubSub统()'ActiveCell.Formula="=sum(a1:f1)/"&i'ActiveCell.FormulaR1C1="=SUM(R[-6]C:R[-1]C)/"&i&""'Application.Run"Book2.xls!Macro1"'清除不必要数据MsgBox"请先设好暂座标志"Application.Run"清"'初始化班级个数平均基数Dimi,m,j,n,o,jm,zh,li,newRangeAsInteger'Dimi,m,j,n,o,newRangeAsIntegerDimtellMeAsStringOnErrorGoToVeryEndtellMe="请输入一个平均基数"tellMe2="请输入一个正确的最大班级个数"i=Application.InputBox(prompt:=tellMe,Title:="平均基数",Default:=50,Type:=1)m=Application.InputBox(prompt:=tellMe2,Title:="班级个数",Default:=8,Type:=1)Ifi=FalseThenExitSubIfm=FalseThenExitSubVeryEnd:'求各班各科平均分'科目Range("D2").Range("A1:I1").SelectSelection.CopyRange("Q2").SelectSelection.PasteSpecialPaste:=xlPasteValuesAndNumberFormats,Operation:=_xlNone,SkipBlanks:=False,Transpose:=FalseRange("z2")="政史"'取得政史列号Forjm=17To30IfCells(2,jm)="政治"Thenzh=jmElseIfCells(2,jm)="历史"Thenli=jmEndIfNext'班级j=1'执行的班级个数n=83'执行的求平均行号定位o=3'执行聚集行号定位Whilej<=mRange("d"&n&"").FormulaArray="=AVERAGE(LARGE(R[-80]C:R[-1]C,ROW(R1:R"&i&")))"Range("d"&n&"").SelectSelection.AutoFillDestination:=ActiveCell.Range("A1:I1"),Type:=_xlFillDefaultActiveCell.Range("A1:I1").SelectSelection.CopyRange("q"&o&"").SelectSelection.PasteSpecialPaste:=xlPasteValuesAndNumberFormats,Operation:=_xlNone,SkipBlanks:=False,Transpose:=FalseRange("z"&o&"").SelectOnErrorResumeNext'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+81j=j+1o=o+1Wend'求年平均分Range("q"&o&"").SelectActiveCell.FormulaR1C1="=SUM(R[-"&m&"]C:R[-1]C)/"&m&""Selection.AutoFillDestination:=ActiveCell.Range("A1:J1"),Type:=_xlFillDefaultActiveCell.Offset(0,-1).Range("A1").SelectActiveCell.FormulaR1C1="年平"'设置格式为“2”位小数(红色)Range("Q3:Z12").SelectSelection.NumberFormatLocal="[红色]0.00_;[红色]-0.00"'清空多余列'DimjmAsIntegerForjm=17To30IfCells(2,jm)="总分"ThenColumns(jm).ClearContentsElseIfCells(2,jm)="年名"ThenColumns(jm).ClearContentsElseIfCells(2,jm)="班名"ThenColumns(jm).ClearContentsEndIfNext'清空无效数据ForEachcInRange(Range("A1"),ActiveCell.SpecialCells(xlLastCell))IfIsError(c)Thenc.ClearContentsEndIfNextcEndSubThisbook代码:PrivateSubWorkbook_Open()Workbook_AddinInstall'AddNewCommandBarEndSubPrivateSubWorkbook_AddinInstall()DimCBAsCommandBarControlDimiAsIntegeri=1ForEachCBInApplication.CommandBars(1).ControlsIfCB.Caption="成绩处理"Then '菜单已加入,则刪除Application.CommandBars("WorksheetMenuBar").Controls("成绩处理「.Visible=TrueApplication.CommandBars("WorksheetMenuBar").Controls("成绩处理").DeleteEndIfNextDimobjCmdBrPpAsCommandBarPopupSet objCmdBrPp =Application.CommandBars.ActiveMenuBar.Controls.Add(Type:=msoControlPopup,Temporary:=False)OnErrorResumeNextobjCmdBrPp.Caption="成绩处理"SetobjCmdBrPp=NothingWithApplication.CommandBars("Worksheetmenubar").Controls("成绩处理").Controls.Add(Type:=msoControlButton,Before:=1).Caption="清".Controls(“清").OnAction="清"EndWithWithApplication.CommandBars("Worksheetmenubar").Controls("成绩处理").Controls.Add(Type:=msoControlButton,Before:=1).Caption="统".Controls(”统").OnAction="统"EndWith'建立工具栏DimxBarAsCommandBarDimxButton1AsCommandBarButtonDimxButton2AsCommandBarButtonOnErrorResumeNextApplication.CommandBars("CustomBar").DeleteSetxBar=Application.CommandBars.Add(Name:="成绩处理",Position:=msoBarTop,MenuBar:=False,Temporary:=False)SetxButton1=xBar.Controls.Add(Type:=msoControlButton)SetxButton2=xBar.Controls.Add(Type:=msoControlButton)WithxButton1.Caption="清".Style=msoButtonCaption.OnAction="清"EndWithWithxButton2.Caption="统".Style=msoButtonCaption.OnAction="统"EndWithWithApplication.CommandBars("成绩处理").Visible=TrueEndWithSetxBar=NothingSetxButton1=NothingSetxButton2=Nothing'固定工具栏DimintleftAsInteger,introwAsIntegerintleft=Application.CommandBars("formatting").Widthintrow=Application.CommandBars("formatting").RowIndexApplication.CommandBars("成绩处理").Left=intleftApplication.CommandBars("成绩处理").RowIndex=introwEndSubPrivateSubWorkbook_BeforeClose(CancelAsBoolean)'文件关闭,就刪除菜单DimCBAsCommandBarControlOnErrorResumeNextForEachCBInApplication.CommandBars(1).ControlsIfCB.Caption="成绩处理"ThenAppli
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 专升本思政解题策略试题及答案
- 专升本思政知识扩展试题及答案
- 康柏西普眼用注射液-药品临床应用解读
- 2024年思政理论分析框架试题及答案
- 设计师劳动合同范本
- 分布式计算、云计算与大数据 第2版 课件 第7章 云原生技术
- 图书馆服务流程试题与答案解析
- 跨文化管理与马工学的对接试题及答案
- 老年复习测试卷附答案
- 马工学与信息系统的互动分析试题及答案
- T-CBJ 3108-20221 无醇啤酒标准
- T-CHIDA 02-2022 T-CWEC 33-2022 城市水环境综合治理技术指南
- 2025年长沙轨道交通职业学院单招综合素质考试题库完美版
- 2025年高考作文备考之一人写遍热点话题:雷军站在时代的风口(金句+作文运用+范文)
- GIS知识培训课件
- 2025美国急性冠脉综合征(ACS)患者管理指南解读课件
- 脑脊液检查11课件
- 医院股东章程范本
- 2025年江苏省高职单招《职测》高频必练考试题库400题(含答案)
- 2025年四川省宜宾市“两海”示范区招聘雇员制聘用人员12人历年高频重点模拟试卷提升(共500题附带答案详解)
- 易制毒易制爆培训
评论
0/150
提交评论