ExcelHome技术论坛

 找回密码
 免费注册

QQ登录

只需一步,快速开始

快捷登录

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

生产自动排程VBA代码注释

[复制链接]

TA的精华主题

TA的得分主题

发表于 2011-9-17 11:41 | 显示全部楼层 |阅读模式
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件       ★免费下载 ★       ★ 使用帮助
以下是生产排程自动代码,我不懂得是什么意思,请这方面的老师帮手注释一下,急用!谢谢了!
Public bstm, bstm1, bstm11, bstm12, bstm13
Sub auto_open()
    Set bstm = CommandBars("worksheet menu bar")
    Set bstm1 = bstm.Controls.Add(Type:=msoControlPopup)
    bstm1.Caption = "make schedule"
   
    Set bstm11 = bstm1.Controls.Add(Type:=msoControlButton)
    With bstm11
        .Caption = "make schedule"
        .OnAction = "line"
        .FaceId = 166
    End With
   
    Set bstm12 = bstm1.Controls.Add(Type:=msoControlButton)
    With bstm12
        .Caption = "sort"
        .OnAction = "sort"
        .FaceId = 176
    End With
    Set bstm13 = bstm1.Controls.Add(Type:=msoControlButton)
    With bstm13
        .Caption = "sheet management"
        .OnAction = "show"
        .FaceId = 177
    End With
End Sub
Sub auto_close()
    CommandBars("worksheet menu bar").Controls("make schedule").Delete
End Sub
Sub line()
Dim i As Integer
z = 3
Do While Not Sheets("sheet1").Range("A" & z).Value = ""
z = z + 1
Loop
z = z - 1
Set mydocument = Worksheets(1)
mydocument.Activate
Range(Cells(6, 14), Cells(15, 140)).ClearContents
Range(Cells(6, 14), Cells(15, 140)).Interior.ColorIndex = xlNone
For Each rs In mydocument.Shapes
rs.Delete
Next rs
Cells(4, 14).Value = Sheets("sheet1").Range("H" & 3).Value
m = 115
l = 14
s = 14
For i = 3 To z
If Sheets("sheet1").Range("M" & i).Value = "" Then
k = Sheets("sheet1").Range("J" & i).Value
Else
k = Sheets("sheet1").Range("M" & i).Value
End If
Cells(7, l).Value = Sheets("sheet1").Range("A" & i).Value
Cells(8, l).Value = Sheets("sheet1").Range("B" & i).Value
Cells(9, l).Value = Sheets("sheet1").Range("C" & i).Value
Cells(10, l).Value = Sheets("sheet1").Range("D" & i).Value
Cells(11, l).Value = Sheets("sheet1").Range("E" & i).Value
Cells(12, l).Value = Sheets("sheet1").Range("F" & i).Value
Cells(13, l).Value = "'" & Sheets("sheet1").Range("G" & i).Value
Cells(14, l).Value = k & "H"
Cells(15, l).Value = "'" & Sheets("sheet1").Range("I" & i).Value & ":00"
n = m + 7.5 * k
With mydocument.Shapes.AddLine(m, 230, n, 230).line
    .DashStyle = msoLineSolid
    .Weight = 3
    .ForeColor.RGB = RGB(0, 0, 255)
    .EndArrowheadLength = msoArrowheadLong
    .EndArrowheadStyle = msoArrowheadTriangle
    .EndArrowheadWidth = msoArrowheadWide
End With
m = n
s = s + 0.5 * k
l = Int(s)
Next
y = 3
Do While Not Sheets("sheet1").Range("A" & y).Value = "SMT LINE2"
y = y + 1
Loop
y = y - 1
z = y + 4
Do While Not Sheets("sheet1").Range("A" & z).Value = ""
z = z + 1
Loop
z = z - 1
Set mydocument = Worksheets(1)
mydocument.Activate
Range(Cells(18, 14), Cells(27, 140)).ClearContents
Range(Cells(18, 14), Cells(27, 140)).Interior.ColorIndex = xlNone
m = 115
l = 14
s = 14
For i = y + 4 To z
If Sheets("sheet1").Range("M" & i).Value = "" Then
k = Sheets("sheet1").Range("J" & i).Value
Else
k = Sheets("sheet1").Range("M" & i).Value
End If
Cells(18, l).Value = Sheets("sheet1").Range("A" & i).Value
Cells(19, l).Value = Sheets("sheet1").Range("B" & i).Value
Cells(20, l).Value = Sheets("sheet1").Range("C" & i).Value
Cells(21, l).Value = Sheets("sheet1").Range("D" & i).Value
Cells(22, l).Value = Sheets("sheet1").Range("E" & i).Value
Cells(23, l).Value = Sheets("sheet1").Range("F" & i).Value
Cells(24, l).Value = "'" & Sheets("sheet1").Range("G" & i).Value
Cells(25, l).Value = k & "H"
Cells(26, l).Value = "'" & Sheets("sheet1").Range("I" & i).Value & ":00"
n = m + 7.5 * k
With mydocument.Shapes.AddLine(m, 395, n, 395).line
    .DashStyle = msoLineSolid
    .Weight = 3
    .ForeColor.RGB = RGB(0, 0, 255)
    .EndArrowheadLength = msoArrowheadLong
    .EndArrowheadStyle = msoArrowheadTriangle
    .EndArrowheadWidth = msoArrowheadWide
End With
m = n
s = s + 0.5 * k
l = Int(s)
Next
End Sub
Sub sort()
Dim z As Integer, p As Integer
p = 0
        z = 3
Do While Not Sheets("sheet1").Range("A" & z).Value = ""
z = z + 1
Loop
z = z - 1
p = z
Sheets("sheet1").Activate
Range(Cells(3, 1), Cells(z, 14)).Select
    Selection.sort Key1:=Range("N3"), Order1:=xlAscending, Header:=xlGuess, _
        OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, SortMethod _
        :=xlStroke, DataOption1:=xlSortNormal
y = 3
Do While Not Sheets("sheet1").Range("A" & y).Value = "SMT LINE2"
y = y + 1
Loop
y = y - 1
z = y + 5
Do While Not Sheets("sheet1").Range("A" & z).Value = ""
z = z + 1
Loop
z = z - 1
Sheets("sheet1").Activate
Range(Cells(y + 5, 1), Cells(z, 14)).Select
    Selection.sort Key1:=Range("N4"), Order1:=xlAscending, Header:=xlGuess, _
        OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, SortMethod _
        :=xlStroke, DataOption1:=xlSortNormal
        For i = 4 To p
        Range("H" & i).Select
         ActiveCell.FormulaR1C1 = "=R[-1]C[3]"
         Range("I" & i).Select
         ActiveCell.FormulaR1C1 = "=R[-1]C[3]"
         Next
End Sub
Sub show()
UserForm.show
End Sub

TA的精华主题

TA的得分主题

 楼主| 发表于 2011-9-24 21:31 | 显示全部楼层
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件       ★免费下载 ★       ★ 使用帮助
真没劲,就没有一个人可以注释的吗?

TA的精华主题

TA的得分主题

发表于 2012-12-11 12:28 | 显示全部楼层
chaintang 发表于 2011-9-24 21:31
真没劲,就没有一个人可以注释的吗?

上个附件吧
您需要登录后才可以回帖 登录 | 免费注册

本版积分规则

关闭

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

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

GMT+8, 2024-12-24 03:30 , Processed in 0.041637 second(s), 10 queries , Gzip On, MemCache On.

Powered by Discuz! X3.4

© 1999-2023 Wooffice Inc.

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

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

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