Dim dGoal As Object
Dim dCls As Object
Sub 制作联合成绩条() Dim sht As Worksheet
Dim HeadRng As Range
Dim Header As Variant
Dim Arr As Variant
Dim Brr As Variant Set sht = ThisWorkbook.Worksheets("成绩条模板")
Set HeadRng = sht.Range("A1:Z1")
Header = HeadRng.Value
Arr = GetClass()
Brr = GetExam()
Set dGoal = CreateObject("Scripting.Dictionary")
Set dCls = CreateObject("Scripting.Dictionary")
Call GetGoal
'Debug.Print UBound(Arr) - LBound(Arr) + 1
For i = LBound(Arr) To UBound(Arr)
'Debug.Print Arr(i)
SheetName = CStr(Arr(i))
Set sht = CreateSheet(ThisWorkbook, SheetName) With sht
For Each OneKey In dCls.Keys
If dCls(OneKey) = SheetName Then
EndRow = .Cells(.Cells.Rows.Count, 2).End(xlUp).Row + 2
If EndRow = 3 Then EndRow = 1
'Debug.Print EndRow
Set Rng = .Cells(EndRow, 1)
Set Rng = Rng.Resize(UBound(Header), UBound(Header, 2))
Rng.Value = Header
Set Rng = .Cells(EndRow, 1).Offset(1, 1).Resize(UBound(Brr), 1)
Rng.Value = Application.WorksheetFunction.Transpose(Brr)
Set Rng = .Cells(EndRow, 1).CurrentRegion
Ar = Rng.Value
Ar(2, 1) = "高三" & SheetName & "班"
Ar(3, 1) = "'" & OneKey
Ar(4, 1) = dGoal(Ar(2, 2) & ";" & OneKey & ";" & "姓名")
For x = LBound(Ar) + 1 To UBound(Ar)
For y = LBound(Ar, 2) + 2 To UBound(Ar, 2)
Key = Ar(x, 2) & ";" & OneKey & ";" & Ar(1, y)
Ar(x, y) = dGoal(Key)
Next y
Next x
Rng.Value = Ar
SetBorders Rng
SetCenters Rng
End If
Next OneKey .UsedRange.Columns.AutoFit
For Each OneRow In .UsedRange.Rows
OneRow.RowHeight = 16.5
Next OneRow With .PageSetup .PrintTitleRows = ""
.PrintTitleColumns = ""
.PrintArea = ""
.LeftHeader = ""
.CenterHeader = ""
.RightHeader = ""
.LeftFooter = ""
.CenterFooter = ""
.RightFooter = ""
.LeftMargin = Application.InchesToPoints(0.7)
.RightMargin = Application.InchesToPoints(0.7)
.TopMargin = Application.InchesToPoints(0.75)
.BottomMargin = Application.InchesToPoints(0.75)
.HeaderMargin = Application.InchesToPoints(0.3)
.FooterMargin = Application.InchesToPoints(0.3)
.PrintHeadings = False
.PrintGridlines = False
.PrintComments = xlPrintNoComments
.PrintQuality = 600
.CenterHorizontally = False
.CenterHorizontally = True
.CenterVertically = True
.Orientation = xlLandscape
.Draft = False
.PaperSize = xlPaperA4
.FirstPageNumber = xlAutomatic
.Order = xlDownThenOver
.BlackAndWhite = False
.Zoom = 100
.PrintErrors = xlPrintErrorsDisplayed
.OddAndEvenPagesHeaderFooter = False
.DifferentFirstPageHeaderFooter = False
.ScaleWithDocHeaderFooter = True
.AlignMarginsHeaderFooter = True
.EvenPage.LeftHeader.Text = ""
.EvenPage.CenterHeader.Text = ""
.EvenPage.RightHeader.Text = ""
.EvenPage.LeftFooter.Text = ""
.EvenPage.CenterFooter.Text = ""
.EvenPage.RightFooter.Text = ""
.FirstPage.LeftHeader.Text = ""
.FirstPage.CenterHeader.Text = ""
.FirstPage.RightHeader.Text = ""
.FirstPage.LeftFooter.Text = ""
.FirstPage.CenterFooter.Text = ""
.FirstPage.RightFooter.Text = "" End With
.Activate
ActiveWindow.View = xlPageBreakPreview
ActiveWindow.Zoom = 100
End With
Next i Set dGoal = Nothing
Set dCls = Nothing End Sub
Private Sub GetGoal()
Dim OneSht As Worksheet
Dim ExamName As String
Dim stdId As String
Dim stdName As String
Dim stdClass As String
Dim EndRow As Long, EndCol As Long For Each OneSht In ThisWorkbook.Worksheets
If OneSht.Name Like "成绩表*" Then
With OneSht
ExamName = Replace(.Name, "成绩表_", "")
EndRow = .Cells(.Cells.Rows.Count, 1).End(xlUp).Row
EndCol = .Cells(1, .Cells.Columns.Count).End(xlToLeft).Column
For i = 2 To EndRow stdId = CStr(.Cells(i, 1).Text)
'Debug.Print stdId
stdName = CStr(.Cells(i, 2).Text)
stdcls = CStr(.Cells(i, 3).Text) dCls(stdId) = stdcls
For J = 1 To EndCol
Key = ExamName & ";" & stdId & ";" & .Cells(1, J).Text
'Debug.Print Key
dGoal(Key) = .Cells(i, J).Text
Next J
Next i
End With
End If
Next OneSht
End Sub
Private Function GetClass() As Variant
Dim OneSht As Worksheet
Dim Cls As String, Tmp As String
For Each OneSht In ThisWorkbook.Worksheets
If OneSht.Name Like "成绩表*" Then
With OneSht
EndRow = .Cells(.Cells.Rows.Count, 3).End(xlUp).Row
For i = 2 To EndRow
Tmp = "|" & .Cells(i, 3).Text
If InStr(Cls, Tmp) = 0 Then
Cls = Cls & Tmp
End If
Next i
End With
End If
Next OneSht
Cls = Mid(Cls, 2)
Debug.Print Cls
GetClass = Split(Cls, "|")
End Function
Public Function CreateSheet(ByVal Wb As Workbook, ByVal SheetName As String) As Worksheet
Application.DisplayAlerts = False
Dim NewSht As Worksheet, LastSht As Worksheet
On Error Resume Next
Set NewSht = Wb.Worksheets(SheetName)
If Not NewSht Is Nothing Then NewSht.Delete
On Error GoTo 0
Set LastSht = Wb.Worksheets(Wb.Worksheets.Count)
Set NewSht = Wb.Worksheets.Add(after:=LastSht)
NewSht.Name = SheetName
Set CreateSheet = NewSht
Set LastSht = Nothing
Set NewSht = Nothing
Set Wb = Nothing
Application.DisplayAlerts = True
End Function
Private Function GetExam() As Variant
Dim Ar() As String
Dim i As Long
i = 0
ReDim Ar(1 To 1)
For Each OneSht In ThisWorkbook.Worksheets
If OneSht.Name Like "成绩表*" Then
i = i + 1
ExamName = Replace(OneSht.Name, "成绩表_", "")
ReDim Preserve Ar(1 To i)
Ar(i) = ExamName
End If
Next OneSht
GetExam = Ar
End Function
Private Sub SetBorders(ByVal Rng As Range)
With Rng.Borders
.LineStyle = xlContinuous
.ColorIndex = xlAutomatic
.TintAndShade = 0
.Weight = xlThin
End With
End Sub
Private Sub SetCenters(ByVal Rng As Range)
With Rng
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
End With
End Sub

  

20171104xlVBA制作联合成绩条的更多相关文章

  1. 20181013xlVba据成绩条生成图片文件

    Sub CreateGoalPictures() '声明变量 Dim Wb As Workbook Dim Sht As Worksheet Dim Shp As Shape Dim Pic, End ...

  2. CSS3制作同心圆进度条

    1.css代码 此处在制作进度条时,是旋转进度条的半圆(红色),背景使用灰白(如果使用红色作为背景,旋转灰白遮罩,在浏览器中可能会有渲染bug) .wrapper{ display:block;pos ...

  3. JS-纯js制作动态成绩表(流程控制语句+js内置对象)

    流程控制for循环+if判断+Math对象+Array对象+Date对象制作成绩表 <!DOCTYPE html><html> <head> <meta ch ...

  4. iOS 开发技巧-制作环形进度条

    有几篇博客写到了怎么实现环形进度条,大多是使用Core Graph来实现,实现比较麻烦且效率略低,只是一个小小的进度条而已,我们当然是用最简单而且效率高的方式来实现. 先看一下这篇博客,博客地址:ht ...

  5. CSS制作环形进度条

    参考来源 <Radial progress indicator using CSS>,该文核心是用纯CSS来做一个环形的进度条.纯css的意思就是连百分比这种数字,都是css生成的.文章作 ...

  6. unity制作简单血条

    学习Unity已经10天了,也没发现有什么长进,真的急.昨天仿着官方Demo做了个射击游戏轮廓,其中需要给每个怪做一个血条. 搜了一些,挺复杂的,用NGUI或者UGUI,外加很长的代码...不过还是找 ...

  7. 移动端纯CSS3制作圆形进度条所遇到的问题

    近日在开发的页面中,需要制作一个动态的圆形进度条,首先想到的是利用两个矩形,宽等于直径的一半,高等于直径,两个矩形利用浮动贴在一起,设置overflow:hidden属性,作为盒子,内部有一个与其宽高 ...

  8. 浅谈一下关于使用css3来制作圆环进度条

    最近PC端项目要做一个这样的页面出来,其他的都很简单,关键在于百分比的圆环效果.我最初打算是直接使用canvas来实现的,因为canvas实现一个圆是很简便的. 下面贴出canvas实现圆环的代码,有 ...

  9. 用jquery制作加载条

    <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> ...

随机推荐

  1. 【MonkeyRunner环境搭建】

    一.配置MonkeyRunner环境变量 1.首先下载一个AndroidSDK,在SDK的目录中的tools文件夹中,直接带有MonkeyRunner 2.打开MonkeyRunner的方式: |-- ...

  2. topcoder srm 450 div1

    problem1 link 用$f[i][0],f[i][1]$表示从$i$位置开始Alice是先手是否可以胜利,是后手是否可以胜利. problem2link 每次钱数够$price$时可以选择使得 ...

  3. CentOS7下Docker中构建可以自动发布到项目的Tomcat容器

    步骤 下载镜像 搜索相应的镜像文件:docker search 'tomcat' 如下 下载镜像:docker pull tomcat:7,如下图 PS:后面的数字代表tomcat的版本,可以自己选择 ...

  4. Eclipse的Servers视图中无法添加Tomcat

    问题:Eclipse的Servers视图中无法添加Tomcat,其中ServerName是被置为灰色的,无法编辑,如下图所示: 解决步骤: 关闭Eclipse 找到Eclipse的工作区间,这里假设命 ...

  5. checkbox勾选事件,JQ设置css,下拉框JQ选中

    <input id="CheckMainCompany" type="checkbox"/> $(function() { $("#Che ...

  6. Python3基础 frozenset 使用list创建frozenset

             Python : 3.7.0          OS : Ubuntu 18.04.1 LTS         IDE : PyCharm 2018.2.4       Conda ...

  7. 第一次怎么把本地git仓库的内容push到远程仓库?

    使用git push origin <分支名> -f 这种方式可以用本地仓库的内容覆盖远程仓库.

  8. Git学习笔记---协作的一般流程

    一般的操作流程 1.pull 王小坤与另一个同事张大炮一起开发一个项目,张大炮昨天修改了数据库读写的api,优化了执行速度,并把read()函数改名成了Read(),下午下班之前把这些代码push到服 ...

  9. 如何清除浮动塌陷? float:left 塌陷

    参考文章: http://www.jb51.net/css/502268.html 原文链接:http://www.jianshu.com/p/a0500b54da13 只要给li的宽度, 规定得小一 ...

  10. POJ 2018 Best Cow Fences(二分最大区间平均数)题解

    题意:给出长度>=f的最大连续区间平均数 思路:二分这个平均数,然后O(n)判断是否可行,再调整l,r.判断方法是,先求出每个数对这个平均数的贡献,再求出长度>=f的最大贡献的区间,如果这 ...