从朋友那得到以下程序,可以把图片1转变为图片二,但本人对VB了解不深,图片3是我想举一反三的,还请各位大侠指教,此程序的具体意思是什么?特别是红色的部分,修改它我估计可以举一反三了,谢谢!
图片1:
图片2:
图片3--:
Sub iWearer()
Dim I, K
Application.ScreenUpdating = False
Cells.Select
Selection.UnMerge
I = Range("A65536").End(xlUp).Row
Rows(I).Select
Selection.Delete Shift:=xlUp
Columns("A:A").Select
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
Range("A22").Select
ActiveCell.FormulaR1C1 = _
"=IF(AND(LEFT(RC[1],7)<>""Product"",RC[37]<>""""),""Y"","""")"
Range("A22").Select
Selection.Copy
Range("A1:A2").Resize(I - 1, 1).Select
ActiveSheet.Paste
Application.CutCopyMode = False
For K = 1 To I - 1
Range("A1").Offset(K, 0).Select
If Range("A1").Offset(K, 0).Value = "Y" Then
Selection.Delete Shift:=xlToLeft
End If
Next K
Columns("A:A").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Range("A1:I1").Select
Selection.EntireColumn.Insert , CopyOrigin:=xlFormatFromLeftOrAbove
ActiveWindow.Zoom = 85
Range("J1").Select
ActiveCell.FormulaR1C1 = "Product"
Range("A1").Select
ActiveCell.FormulaR1C1 = "Customer"
Range("B1").Select
ActiveCell.FormulaR1C1 = "Wearer"
Range("C1").Select
ActiveCell.FormulaR1C1 = "WO"
Range("D1").Select
ActiveCell.FormulaR1C1 = "Reason"
Range("E1").Select
ActiveCell.FormulaR1C1 = "Size"
Range("F1").Select
ActiveCell.FormulaR1C1 = "Order"
Range("G1").Select
ActiveCell.FormulaR1C1 = "Done"
Range("H1").Select
ActiveCell.FormulaR1C1 = "Open"
Range("I1").Select
ActiveCell.FormulaR1C1 = "Del.Date"
Range("J1").Select
ActiveWindow.SmallScroll ToRight:=-2
Range("A2").Select
Range("A2").Select
ActiveCell.FormulaR1C1 = "=IF(LEFT(RC[10],5)=""Custo"",TRIM(RC[14]),R[-1]C)"
Range("B2").Select
ActiveCell.FormulaR1C1 = "=IF(LEFT(R[-1]C[9],7)=""Wearer#"",RC[9],R[-1]C)"
Range("C2").Select
ActiveCell.FormulaR1C1 = _
"=IF(LEFT(RC[8],16)=""Workorder Number"",RC[17],R[-1]C)"
Range("D2").Select
ActiveCell.FormulaR1C1 = "=IF(LEFT(RC[7],10)=""Order date"",RC[27],R[-1]C)"
Range("E2").Select
ActiveCell.FormulaR1C1 = "=IF(RC[5]<>"""",RC[25],"""")"
Range("F2").Select
ActiveCell.FormulaR1C1 = "=IF(RC[4]<>"""",RC[35],"""")"
Range("G2").Select
ActiveCell.FormulaR1C1 = "=IF(RC[3]<>"""",RC[37],"""")"
Range("H2").Select
ActiveCell.FormulaR1C1 = "=IF(RC[2]<>"""",RC[38],"""")"
Range("I2").Select
ActiveCell.FormulaR1C1 = "=IF(LEFT(RC[2],13)=""Delivery date"",RC[11],R[-1]C)"
Range("I3").Select
Range("A2:I2").Select
Selection.Copy
Range("A2:I2").Resize(I - 1, 9).Select
ActiveSheet.Paste
Application.CutCopyMode = False
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
'GoTo 100
Columns("J:J").Select
Application.CutCopyMode = False
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
Range("J1").Value = "Remark"
Range("J10").Select
ActiveCell.FormulaR1C1 = "=IF(RC[11]="""",R[-1]C,RC[11])"
Range("J10").Select
Selection.AutoFill Destination:=Range("J10").Resize(I - 9, 1)
Range("J10").Resize(I - 9, 1).Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Range("A2:k2948").Resize(I, 11).Select
100
Selection.AutoFilter
ActiveSheet.Range("$A$2:$k$2948").Resize(I, 11).AutoFilter Field:=6, Criteria1:="="
Selection.EntireRow.Delete
Columns("L:AZ").Select
Selection.Delete Shift:=xlToLeft
Cells.Select
With Selection.Font
.Name = "Arial"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.TintAndShade = 0
.ThemeFont = xlThemeFontNone
End With
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
Selection.Borders(xlEdgeLeft).LineStyle = xlNone
Selection.Borders(xlEdgeTop).LineStyle = xlNone
Selection.Borders(xlEdgeBottom).LineStyle = xlNone
Selection.Borders(xlEdgeRight).LineStyle = xlNone
Selection.Borders(xlInsideVertical).LineStyle = xlNone
Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
Selection.Font.Bold = True
Selection.Font.Bold = False
Range("A2").Select
Application.ScreenUpdating = True
End Sub