- 帖子
- 97
- 主題
- 33
- 精華
- 0
- 積分
- 129
- 點名
- 0
- 作業系統
- Win 7
- 軟體版本
- office 2007
- 閱讀權限
- 20
- 性別
- 男
- 註冊時間
- 2019-5-7
- 最後登錄
- 2022-8-25
|
程式內容是將sheet1篩選後的資料複製到sheet2的合併儲存格
目前錄製的方法是複製到sheet2後,再合併儲存格
sheet1的資料是變動的
sheet2的合併儲存格是以5列合併為準
希望能用迴圈或其他方式簡化程式碼- Sub 巨集2()
- Range("E9:G15").Select
- Selection.AutoFilter
- ActiveSheet.Range("$E$9:$G$15").AutoFilter Field:=1, Criteria1:="=目視", _
- Operator:=xlOr, Criteria2:="=游標卡尺"
- Range("A9").Select
- Selection.Copy
- Sheets("工作表3").Select
- Range("A13").Select
- Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
- :=False, Transpose:=False
- Sheets("工作表1").Select
- Range("A11").Select
- Application.CutCopyMode = False
- Selection.Copy
- Sheets("工作表3").Select
- Range("A18").Select
- Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
- :=False, Transpose:=False
- Sheets("工作表1").Select
- Range("A14").Select
- Application.CutCopyMode = False
- Selection.Copy
- Sheets("工作表3").Select
- Range("A23").Select
- Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
- :=False, Transpose:=False
- Sheets("工作表1").Select
- Range("A15").Select
- Application.CutCopyMode = False
- Selection.Copy
- Sheets("工作表3").Select
- Range("A28").Select
- Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
- :=False, Transpose:=False
- Sheets("工作表1").Select
- Range("B9:D9").Select
- Application.CutCopyMode = False
- Selection.Copy
- Sheets("工作表3").Select
- Range("B13").Select
- Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
- :=False, Transpose:=False
- Sheets("工作表1").Select
- Range("B11:D11").Select
- Application.CutCopyMode = False
- Selection.Copy
- Sheets("工作表3").Select
- Range("B18").Select
- Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
- :=False, Transpose:=False
- Sheets("工作表1").Select
- Range("B14:D14").Select
- Application.CutCopyMode = False
- Selection.Copy
- Sheets("工作表3").Select
- Range("B23").Select
- Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
- :=False, Transpose:=False
- Sheets("工作表1").Select
- Range("B15:D15").Select
- Application.CutCopyMode = False
- Selection.Copy
- Sheets("工作表3").Select
- Range("B28").Select
- ActiveSheet.Paste
- Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
- :=False, Transpose:=False
- Sheets("工作表1").Select
- Range("E9:G9").Select
- Application.CutCopyMode = False
- ActiveCell.FormulaR1C1 = "目視"
- Sheets("工作表3").Select
- Range("B13").Select
- ActiveCell.FormulaR1C1 = "SIPCSS002-00目視"
- Range("B14").Select
- Sheets("工作表1").Select
- Range("E11:G11").Select
- ActiveCell.FormulaR1C1 = "游標卡尺"
- Sheets("工作表3").Select
- Range("B18").Select
- ActiveCell.FormulaR1C1 = "φ19.93-20.07 游標卡尺"
- Range("B19").Select
- Sheets("工作表1").Select
- Range("E14:G14").Select
- ActiveCell.FormulaR1C1 = "游標卡尺"
- Sheets("工作表3").Select
- Range("B23").Select
- ActiveCell.FormulaR1C1 = "14.90-15.10 游標卡尺"
- Range("B24").Select
- Sheets("工作表1").Select
- Range("E15:G15").Select
- ActiveCell.FormulaR1C1 = "目視"
- Sheets("工作表3").Select
- Range("B28").Select
- ActiveCell.FormulaR1C1 = "袋裝 目視"
- Range("A13:A17").Select
- With Selection
- .HorizontalAlignment = xlCenter
- .VerticalAlignment = xlCenter
- .WrapText = False
- .Orientation = 0
- .AddIndent = False
- .IndentLevel = 0
- .ShrinkToFit = False
- .ReadingOrder = xlContext
- .MergeCells = False
- End With
- Selection.Merge
- Range("B13:B17").Select
- With Selection
- .HorizontalAlignment = xlCenter
- .VerticalAlignment = xlCenter
- .WrapText = False
- .Orientation = 0
- .AddIndent = False
- .IndentLevel = 0
- .ShrinkToFit = False
- .ReadingOrder = xlContext
- .MergeCells = False
- End With
- Selection.Merge
- With Selection
- .HorizontalAlignment = xlCenter
- .VerticalAlignment = xlCenter
- .WrapText = True
- .Orientation = 0
- .AddIndent = False
- .IndentLevel = 0
- .ShrinkToFit = False
- .ReadingOrder = xlContext
- .MergeCells = True
- End With
- ActiveCell.FormulaR1C1 = "SIPCSS002-00 目視"
- Range("B13:B17").Select
- ActiveCell.FormulaR1C1 = "SIPCSS002-00 目視"
- Range("A18:A22").Select
- With Selection
- .HorizontalAlignment = xlCenter
- .VerticalAlignment = xlCenter
- .WrapText = False
- .Orientation = 0
- .AddIndent = False
- .IndentLevel = 0
- .ShrinkToFit = False
- .ReadingOrder = xlContext
- .MergeCells = False
- End With
- Selection.Merge
- Range("B18:B22").Select
- With Selection
- .HorizontalAlignment = xlCenter
- .VerticalAlignment = xlCenter
- .WrapText = False
- .Orientation = 0
- .AddIndent = False
- .IndentLevel = 0
- .ShrinkToFit = False
- .ReadingOrder = xlContext
- .MergeCells = False
- End With
- Selection.Merge
- With Selection
- .HorizontalAlignment = xlCenter
- .VerticalAlignment = xlCenter
- .WrapText = True
- .Orientation = 0
- .AddIndent = False
- .IndentLevel = 0
- .ShrinkToFit = False
- .ReadingOrder = xlContext
- .MergeCells = True
- End With
- Range("B18:B22").Select
- ActiveCell.FormulaR1C1 = "φ19.93-20.07 游標卡尺"
- Range("A23:A27").Select
- With Selection
- .HorizontalAlignment = xlCenter
- .VerticalAlignment = xlCenter
- .WrapText = False
- .Orientation = 0
- .AddIndent = False
- .IndentLevel = 0
- .ShrinkToFit = False
- .ReadingOrder = xlContext
- .MergeCells = False
- End With
- Selection.Merge
- Range("B23:B27").Select
- With Selection
- .HorizontalAlignment = xlCenter
- .VerticalAlignment = xlCenter
- .WrapText = False
- .Orientation = 0
- .AddIndent = False
- .IndentLevel = 0
- .ShrinkToFit = False
- .ReadingOrder = xlContext
- .MergeCells = False
- End With
- Selection.Merge
- With Selection
- .HorizontalAlignment = xlCenter
- .VerticalAlignment = xlCenter
- .WrapText = True
- .Orientation = 0
- .AddIndent = False
- .IndentLevel = 0
- .ShrinkToFit = False
- .ReadingOrder = xlContext
- .MergeCells = True
- End With
- ActiveCell.FormulaR1C1 = "14.90-15.10 游標卡尺"
- Range("A28:A32").Select
- With Selection
- .HorizontalAlignment = xlCenter
- .VerticalAlignment = xlCenter
- .Orientation = 0
- .AddIndent = False
- .IndentLevel = 0
- .ShrinkToFit = False
- .ReadingOrder = xlContext
- .MergeCells = False
- End With
- Selection.Merge
- Range("B28:B32").Select
- With Selection
- .HorizontalAlignment = xlCenter
- .VerticalAlignment = xlCenter
- .Orientation = 0
- .AddIndent = False
- .IndentLevel = 0
- .ShrinkToFit = False
- .ReadingOrder = xlContext
- .MergeCells = False
- End With
- Selection.Merge
- With Selection
- .HorizontalAlignment = xlCenter
- .VerticalAlignment = xlCenter
- .WrapText = True
- .Orientation = 0
- .AddIndent = False
- .IndentLevel = 0
- .ShrinkToFit = False
- .ReadingOrder = xlContext
- .MergeCells = True
- End With
- ActiveCell.FormulaR1C1 = "袋裝 目視"
- Range("B33").Select
- Sheets("工作表1").Select
- Selection.AutoFilter
- End Sub
複製代碼
test篩選複製.rar (26.52 KB)
|
|