乔山办公网我们一直在努力
您的位置:乔山办公网 > excel表格制作 > excel成绩表-(纯代码)Excel VBA-WE016「一键完成学生成绩的收集和排序」

excel成绩表-(纯代码)Excel VBA-WE016「一键完成学生成绩的收集和排序」

作者:乔山办公网日期:

返回目录:excel表格制作

Sub Fenshu()Set ws0 = ActiveSheetfpath = [V1]rmax = [A65535].End(xlUp).Row()For i = 1 To 3 If i = 1 Then KeMu = "语文" If i = 2 Then KeMu = "数学" If i = 3 Then KeMu = "英语" cfile = Dir(fpath & "" & "*" & KeMu & "*.xls*") If cfile <> "" Then Set wbTarget = Workbooks.Open(fpath & "" & cfile) Set wsT = wbTarget.Sheets(1) xh = Application.Match("学号", wsT.Range("1:1"), 0) cj = Application.Match("成绩", wsT.Range("1:1"), 0) wsname = wsT.Name rt = wsT.[A65535].End(xlUp).Row() ct = wsT.[AAA1].End(xlToLeft).Column() cke = Application.Match(KeMu, ws0.Range("1:1"), 0) ws0.Range(Cells(2, cke), Cells(rmax, cke)).FormulaR1C1 = _ "=VLOOKUP(RC1,[" & cfile & "]" & wsname & "!C" & _ xh & ":C" & cj & "," & cj - xh + 1 & ",0)" wbTarget.Close cke2 = Application.Match(KeMu & "排序", ws0.Range("1:1"), 0) ws0.Range(Cells(2, cke2 - 1), Cells(rmax, cke2 - 1)) = ws0.Range("B2:B" & rmax).Value ws0.Range(Cells(2, cke2), Cells(rmax, cke2)) = _ ws0.Range(Cells(2, cke), Cells(rmax, cke)).Value ws0.Range(Cells(2, cke2 - 1), Cells(rmax, cke2)).Sort key1:=ws0.Cells(1, cke2) ws0.Columns(cke2).Select With Selection .FormatConditions.AddTop10 .FormatConditions(.FormatConditions.Count).SetFirstPriority .FormatConditions(1).Percent = False .FormatConditions(1).Rank = 5 .FormatConditions(1).TopBottom = xlTop10Top .FormatConditions(1).Interior.Pattern = xlPatternSolid .FormatConditions(1).Interior.ThemeColor = 9 End With Else MsgBox KeMu & ":成绩表找不到" End IfNextRange(Cells(2, 6), Cells(rmax, 6)).FormulaR1C1 = "=SUM(RC3:RC5)"cke2 = Application.Match("总分排序", ws0.Range("1:1"), 0)Range(Cells(2, cke2 - 1), Cells(rmax, cke2 - 1)) = ws0.Range("B2:B" & rmax).ValueRange(Cells(2, cke2), Cells(rmax, cke2)) = Range(Cells(2, 6), Cells(rmax, 6)).ValueRange(Cells(2, cke2 - 1), Cells(rmax, cke2)).Sort key1:=Cells(1, cke2)Columns(cke2).SelectWith Selection .FormatConditions.AddTop10 .FormatConditions(.FormatConditions.Count).SetFirstPriority .FormatConditions(1).Percent = False .FormatConditions(1).Rank = 5 .FormatConditions(1).TopBottom = xlTop10Top .FormatConditions(1).Interior.Pattern = xlPatternSolid .FormatConditions(1).Interior.ThemeColor = 10End WithApplication.ReferenceStyle = xlA1End Sub

本文标签:excel成绩表(71)

相关阅读

  • excel成绩表-excel统计学生成绩

  • 乔山办公网excel表格制作
  • 对于教师而言,经常需要用Excel进行学生成绩统计,会被一些常见问题难住。如何统计不同分数段人数、如何在保持学号不变前提下进行排名、如何将百分制转换成不同分数段与如何用红
关键词不能为空
极力推荐

ppt怎么做_excel表格制作_office365_word文档_365办公网