ExcelHome技术论坛

 找回密码
 免费注册

QQ登录

只需一步,快速开始

快捷登录

搜索
EH技术汇-专业的职场技能充电站 妙哉!函数段子手趣味讲函数 Excel服务器-会Excel,做管理系统 Excel Home精品图文教程库
HR薪酬管理数字化实战 Excel 2021函数公式学习大典 Excel数据透视表实战秘技 打造核心竞争力的职场宝典
300集Office 2010微视频教程 数据工作者的案头书 免费直播课集锦 ExcelHome出品 - VBA代码宝免费下载
用ChatGPT与VBA一键搞定Excel WPS表格从入门到精通 Excel VBA经典代码实践指南
查看: 10726|回复: 33

成绩条制作工具(VBA)

[复制链接]

TA的精华主题

TA的得分主题

发表于 2013-4-12 14:42 | 显示全部楼层 |阅读模式
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件       ★免费下载 ★       ★ 使用帮助
本帖最后由 lzqlaj 于 2013-4-12 15:29 编辑

适用于考试后制作学生个人成绩条。可按班级制作,也可按全部学生制作。带进度条,显示制作进度。制作过程及效果见下图。。
excel文件下载  http://www.yimuhe.com/file-758304.html
网盘下载有广告和本人无关,代码公布在5楼。建议用不到这个东东,最好不要去下载,浪费时间,网盘还会有广告。。


1.png
2.gif

TA的精华主题

TA的得分主题

发表于 2013-4-12 15:00 | 显示全部楼层
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用  · 内置多项VBA编程加强工具       ★ 免费下载 ★      ★使用手册
谢谢了,收藏了

TA的精华主题

TA的得分主题

发表于 2013-4-12 15:05 | 显示全部楼层
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件       ★免费下载 ★       ★ 使用帮助
用心啊,给老师们一个惊喜!

TA的精华主题

TA的得分主题

 楼主| 发表于 2013-4-12 15:09 | 显示全部楼层
朝明 发表于 2013-4-12 15:05
用心啊,给老师们一个惊喜!

以后有时间把多次成绩条也发上来。

TA的精华主题

TA的得分主题

发表于 2013-4-12 15:18 | 显示全部楼层

TA的精华主题

TA的得分主题

 楼主| 发表于 2013-4-12 15:23 | 显示全部楼层
本帖最后由 lzqlaj 于 2013-4-12 15:47 编辑

网盘广告和本人无关,代码公布如下:
Public bjls As Integer
Private Sub ComboBox1_Change()
    On Error Resume Next
    Dim zmhs, k
    If ComboBox1.Value <> "" Then
        Sheets(ComboBox2.Value).Select
        zmhs = Sheets(ComboBox2.Value).Range("a65536").End(xlUp).Row
        If ComboBox1.Value > 1 Then TextBox1.Value = Cells(ComboBox1.Value - 1, 1)
        For k = ComboBox1.Value To zmhs
            If WorksheetFunction.CountA(Rows(k + 1)) = 0 And WorksheetFunction.CountA(Rows(k)) <> 0 Then
                TextBox3.Value = k: Exit For
            End If
        Next k
    End If
End Sub
Private Sub ComboBox2_Change()
    On Error Resume Next
    Dim sht, hs, ls, q, i, TheArray As Variant
    If ComboBox2.Value <> "" Then
        Sheets(ComboBox2.Value).Select
        TextBox3.Value = Sheets(ComboBox2.Value).Range("a65536").End(xlUp).Row
    End If
    If OptionButton1 = True Then TextBox3.Locked = True
    sht = ComboBox2.Value
    hs = Sheets(sht).Cells(65536, 1).End(xlUp).Row
    ls = Sheets(sht).Range("IV" & ComboBox1.Value).End(xlToLeft).Column
    If ComboBox2.Value > 0 Then
        For q = 1 To ls
            If Sheets(sht).Cells(ComboBox1.Value, q).Text = "班级" Then
                bjls = q
                Dim arr1, d As Object
                Set d = CreateObject("scripting.dictionary")
                arr1 = Sheets(sht).Range(Sheets(sht).Cells(ComboBox1.Value + 1, bjls), Sheets(sht).Cells(hs, bjls))
                For i = 1 To UBound(arr1)
                    If Not d.exists(arr1(i, 1)) Then d.Add arr1(i, 1), ""
                Next i
            End If
        Next q
        ComboBox3.Clear
        TheArray = d.keys
        SelectionSort TheArray
        For i = 0 To UBound(TheArray)
            ComboBox3.AddItem TheArray(i)
        Next i
        ComboBox3.AddItem "全部"
    End If
End Sub
Private Sub CommandButton3_Click()
    Unload Me
End Sub
Private Sub CommandButton4_Click()
    Application.ScreenUpdating = False
    Dim bm As String
    Dim cjtcolumn As Integer
    Dim sj, arr, xrows, shtSheet, j, i, k, chd, x, xh, shname, sh, brr, w, k1, g, gs, crr, drr
    sj = TextBox2.Value
    On Error GoTo end1
    bm = Sheets(ComboBox2.Value).Name
    xrows = Sheets(bm).Cells(65536, bjls).End(xlUp).Row
    If ComboBox1.Value = "" Then MsgBox "未填写标题行行号!": Exit Sub
    cjtcolumn = Sheets(bm).Cells(ComboBox1.Value, 256).End(xlToLeft).Column
    brr = Sheets(bm).Range(Cells(ComboBox1.Value, 1), Cells(xrows, cjtcolumn))
    shname = ComboBox2.Value & "成绩条"
    For Each sh In Sheets
        If sh.Name = shname Then
            Application.DisplayAlerts = False
            sh.Delete
            Application.DisplayAlerts = True
        End If
    Next
    ReDim arr(1 To UBound(brr), 1 To UBound(brr, 2))
    If ComboBox3.Value = "" Then MsgBox "未选择班级!": Exit Sub
    If ComboBox3.Value <> "全部" Then
        w = 2
        For g = 1 To UBound(brr, 2)
            arr(1, g) = brr(1, g)
        Next g
        For k1 = 2 To UBound(brr)
            If brr(k1, bjls) = ComboBox3.Text Then
                For g = 1 To UBound(brr, 2)
                    arr(w, g) = brr(k1, g)
                Next g
                w = w + 1
            End If
        Next k1
        gs = w - 1
    Else
        arr = brr
        gs = UBound(brr)
    End If
    Set shtSheet = Sheets.Add(After:=ActiveSheet)
    shtSheet.Name = ComboBox2.Value & "成绩条"
    Cells.Select
    Selection.HorizontalAlignment = xlCenter
    Selection.VerticalAlignment = xlCenter
    Selection.Font.Name = "宋体"
    Selection.Font.Size = 14
    成绩条.Hide
    进度条.Show 0
    ReDim crr(1 To 7, 1 To UBound(arr, 2))
    crr(1, 1) = TextBox1.Value
    For g = 1 To UBound(brr, 2)
        crr(3, g) = arr(1, g)
    Next g
    crr(5, UBound(crr, 2) - 3) = "家长签字:"
    chd = Len(gs - 1 - 1)
    For i = 1 To gs - 1
        drr = crr
        xh = i
        If Len(i) < chd Then
            For x = 1 To chd - Len(i)
                xh = "0" & xh
            Next x
        End If
        drr(2, 1) = sj & "   NO." & xh
        For k = 1 To UBound(arr, 2)
            drr(4, k) = arr(i + 1, k)
        Next k
        Cells(7 * (i - 1) + 1, 1).Resize(7, UBound(drr, 2)) = drr
        Range(Cells(7 * (i - 1) + 1, 1), Cells(7 * (i - 1) + 1, UBound(drr, 2))).Select
        Selection.Merge
        With Selection.Font
            .Name = "宋体"
            .FontStyle = "粗体"
            .Size = 18
        End With
        Range(Cells(7 * (i - 1) + 2, 1), Cells(7 * (i - 1) + 2, UBound(drr, 2))).Select
        Selection.Merge
        Selection.HorizontalAlignment = xlRight
        Range(Cells(7 * (i - 1) + 3, 1), Cells(7 * (i - 1) + 4, UBound(drr, 2))).Borders.LineStyle = xlContinuous
        Range(Cells(7 * (i - 1) + 5, UBound(drr, 2) - 3), Cells(7 * (i - 1) + 6, UBound(drr, 2) - 1)).Select
        With Selection
            .HorizontalAlignment = xlGeneral
            .MergeCells = True
        End With
        Range(Cells(7 * (i - 1) + 6, 1), Cells(7 * (i - 1) + 6, UBound(drr, 2))).Select
        Selection.Borders(xlEdgeBottom).LineStyle = xlDot
        Rows(7 * (i - 1) + 7).RowHeight = Rows("1").RowHeight * 0.5
        j = CStr(Int(i / (gs - 1) * 16))
        进度条.TextBox2 = CStr(Int(i / (gs - 1) * 100)) & "%"
        DoEvents
        With 进度条.TextBox1
            .Value = Application.WorksheetFunction.Rept("n", j)
            .Font.Name = "Wingdings"
            .ForeColor = &HFF0000
            .Font.Size = 18
        End With
    Next i
    Erase arr, brr, crr, drr
    Columns("A:IV").Columns.AutoFit
    进度条.Label1.Caption = "制作成绩条已完成,点击关闭......"
    进度条.Label1.ForeColor = &HFF&
    Unload Me
end1:     Cells(1, 1).Select
    Application.ScreenUpdating = True
End Sub
Private Sub UserForm_Activate()
    On Error Resume Next
    Dim i As Integer
    For i = 1 To 4
        ComboBox1.AddItem i
    Next i
    ComboBox1.Value = 2
    TextBox1.Value = "二中考试成绩条"
    TextBox2.Value = Year(Date) & "年" & Month(Date) & "月" & Day(Date) & "日"
    For i = 1 To Sheets.count
        ComboBox2.AddItem Sheets(i).Name
    Next i
    ComboBox2.Value = ActiveSheet.Name
End Sub
Function SelectionSort(TempArray As Variant)
    Dim MaxVal As Variant
    Dim MaxIndex As Integer
    Dim i, j As Integer
    For i = UBound(TempArray) To 1 Step -1
        MaxVal = TempArray(i)
        MaxIndex = i
        For j = 1 To i
            If TempArray(j) > MaxVal Then
                MaxVal = TempArray(j)
                MaxIndex = j
            End If
        Next j
        If MaxIndex < i Then
            TempArray(MaxIndex) = TempArray(i)
            TempArray(i) = MaxVal
        End If
    Next i
End Function
Sub SelectionSortMyArray()
    Dim TheArray As Variant
    TheArray = Array("one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten")
    SelectionSort TheArray
    For i = 1 To UBound(TheArray)
        MsgBox TheArray(i)
    Next i
End Sub
                                 

TA的精华主题

TA的得分主题

发表于 2013-5-17 23:15 | 显示全部楼层

TA的精华主题

TA的得分主题

发表于 2014-3-7 15:26 | 显示全部楼层

TA的精华主题

TA的得分主题

发表于 2014-3-10 12:59 | 显示全部楼层
广告N多,无法下载。想学习不容易啊,建议楼主贴附件。

TA的精华主题

TA的得分主题

 楼主| 发表于 2014-3-10 15:16 | 显示全部楼层
本帖最后由 lzqlaj 于 2014-3-10 15:17 编辑

1.jpg 浏览器可以拦截广告。见截图,没广告。
您需要登录后才可以回帖 登录 | 免费注册

本版积分规则

关闭

最新热点上一条 /1 下一条

手机版|关于我们|联系我们|ExcelHome

GMT+8, 2024-4-25 13:45 , Processed in 0.039546 second(s), 11 queries , Gzip On, MemCache On.

Powered by Discuz! X3.4

© 1999-2023 Wooffice Inc.

沪公网安备 31011702000001号 沪ICP备11019229号-2

本论坛言论纯属发表者个人意见,任何违反国家相关法律的言论,本站将协助国家相关部门追究发言者责任!     本站特聘法律顾问:李志群律师

快速回复 返回顶部 返回列表