|
[广告] 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
|
|