20171104xlVBA制作联合成绩条

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

  

时间: 2024-10-09 18:47:07

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

Unity UGUI Canvas 使用Slider制作角色血条

最近课程实训选修Unity,讲解的是Unity官方案例--SpaceShoot,培训无聊,便想着给游戏角色制作一下血条,以此增加游戏的可玩性. Unity版本:5.4.1 案例模版:太空射击 原文作者:茄阁云云 原文连接:http://www.cnblogs.com/vmoor2016/p/6044941.html 把一个大象装进冰箱里需要三步:①把冰箱门打开:②把大象塞冰箱里:③关上冰箱门. 那么制作一个角色的血条需要几部呢?在这里也划分为三步:①制作血条:②摆放血条:③操作血条. 下面就来给

CocoStudio使用笔记2:cocos2dx3.9使用CocoStudio制作的进度条LoadingBar

作为菜鸟曾一直使用手写cocos2dx界面,最近一直在研究cocostudio这个工具.尝试着使用工具来快速的开发游戏,折腾了一个多星期了,每天不停的搜索资料. 记录下本人试用cocostudio制作的启动界面所遇到的问题和经验,方便以后查阅. 首先设置编辑器的分辨率为480*800安卓分辨率的大小. 添加一个sprite精灵使用大小为480*800的图片(background.png)作为背景,然后添加sprite精灵作为游戏logo(logo.png),继续添加sprite作为进度条的背景(

纯CSS制作自适应分页条-分享------彭记(019)

纯css制作自适应分页条 效果图: html: <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-wi

澳洲拉筹伯大学LTU文凭文凭制作修改成绩,GPA修改微信:13166038657

[谷歌推荐]剑客渗透联盟打造最顶尖最专业的黑客渗透技术团队,专注国内外主流安全系统渗透技术多年来一直潜心研究互联网安全漏洞的挖掘利用和各类服务器入侵渗透如linux,unix,apach ,hadoop ,tomcat 数据库入侵如mysql mango DB oracle SQL等本团队拥有资深网络安全工程师CCIE CISSP oracle manager 等精英具备十年以上的黑客入侵经验.目前对外接纳业务,我们的服务项目如下:成绩修改,密码破解,窃取数据,商业利益,入侵服务器,网站入侵,外

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

流程控制for循环+if判断+Math对象+Array对象+Date对象制作成绩表 <!DOCTYPE html><html> <head> <meta charset="UTF-8"> <title>综合运用</title> <style type="text/css"> body { text-align: center; font: 14px "微软雅黑";

纯CSS3制作圆形进度条所遇到的问题

近日在开发的页面中,需要制作一个动态的圆形进度条,首先想到的是利用两个矩形,宽等于直径的一半,高等于直径,两个矩形利用浮动贴在一起,设置overflow:hidden属性,作为盒子,内部有一个与其宽高相等的子盒子,左侧的子盒子左上角和左下角以及右侧子盒子的右上角和右下角利用border-radius:半径,这样两个矩形便组成了一个完整的圆形. 我们让左侧的子盒子绕着右边的中点旋转180°,这样左侧的半圆就隐藏了,右侧半圆同理.这个地方设置旋转中心是用的transform-origin属性,第一个

unity制作简单血条

学习Unity已经10天了,也没发现有什么长进,真的急.昨天仿着官方Demo做了个射击游戏轮廓,其中需要给每个怪做一个血条. 搜了一些,挺复杂的,用NGUI或者UGUI,外加很长的代码...不过还是找到了一篇简单的. 但是那一篇把所有的东西都放一起了,不太好,我在这整理分离一下. 背景: 官方Demo恶魔射手.其中每个怪都有一个EnemyHealth脚本,该脚本主要有怪物的血量等,然后有个TakeDamage()函数来计算伤害后的血量. 开始: 1.制作图片: PS一张细长的红色图片作为血量:

进阶教程(8)- 制作载入进度条

载入进度动画条与启动画面一样,有着安抚用户急不可耐的小心脏的重要作用.如果没有一个百分比或者进度条的显示,遇到网络比较慢的情况,可能用户会马上关闭了这个全景链接.尤其是在这个讲求快感的时代,让用户知道还有多久能够看到清晰的全景,你就能多留住更多的客户. 默认的cofu皮肤只有一个"loading"的文字提示,当载入一个新的场景时,只出现一个文字提示是不够的.在官方的安装包的路径 examples\xml-usage\progress 如果直接双击html文件,就能看到下图的进度条动画,

如何使用纯CSS制作特效导航条?

先上张图,如何使用纯 CSS 制作如下效果? 在继续阅读下文之前,你可以先缓一缓.尝试思考一下上面的效果或者动手尝试一下,不借助 JS ,能否巧妙的实现上述效果. OK,继续.这个效果是我在业务开发的过程中遇到的一个类似的小问题.其实即便让我借助 Javascript ,我的第一反应也是,感觉很麻烦啊.所以我一直在想,有没有可能只使用 CSS 完成这个效果呢? 定义需求 我们定义一下简单的规则,要求如下: <ul> <li>不可思议的CSS</li> <li>