|
VBA超初心者です。超基本的な質問で申し訳ないのですが、助けてください。
A列〜E列まで非表示になっている列を再表示させ、J列を選択し1列挿入し右にシフトさせるという処理をマクロの自動記録で記録しました。これを他のブックで実行するとJ列の前後に2行づづつまり余分な4行が挿入されます。下に自動記録のコードを全て記入しますので、どこを直せばよいのかご教授ください。
Sub データ処理()
Cells.Select
Range("F1").Activate
Selection.EntireColumn.Hidden = False
Range("A14:E14").Select
Selection.Cut Destination:=Range("A8:E8")
Range("A15:D17").Select
Selection.Cut Destination:=Range("A9:D11")
Range("A9:D11").Select
ActiveWindow.SmallScroll Down:=6
Range("F15").Select
Selection.AutoFill Destination:=Range("F15:F23")
Range("F15:F23").Select
ActiveWindow.SmallScroll Down:=6
Range("F24").Select
ActiveCell.FormulaR1C1 = "使用制限対象物質"
With ActiveCell.Characters(Start:=1, Length:=8).Font
.Name = "MS Pゴシック"
.FontStyle = "標準"
.Size = 9
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
ActiveCell.Characters(1, 2).PhoneticCharacters = "シヨウ"
ActiveCell.Characters(3, 2).PhoneticCharacters = "セイゲン"
ActiveCell.Characters(5, 2).PhoneticCharacters = "タイショウ"
ActiveCell.Characters(7, 2).PhoneticCharacters = "ブッシツ"
Range("F24").Select
Selection.Copy
Range("F25:F30").Select
ActiveSheet.Paste
ActiveWindow.SmallScroll Down:=9
Range("F31").Select
Application.CutCopyMode = False
Selection.AutoFill Destination:=Range("F31:F43")
Range("F31:F43").Select
ActiveWindow.SmallScroll Down:=-18
Range("F12:I12").Select
Selection.Copy
ActiveWindow.SmallScroll ToRight:=-2
Range("A15:D43").Select
ActiveSheet.Paste
ActiveWindow.SmallScroll ToRight:=5
ActiveWindow.SmallScroll Down:=-3
Columns("J:J").Select
Range("J3").Activate
Application.CutCopyMode = False
Selection.Insert Shift:=xlToRight
Range("J14").Select
ActiveCell.FormulaR1C1 = "質量"
With ActiveCell.Characters(Start:=1, Length:=2).Font
.Name = "MS Pゴシック"
.FontStyle = "標準"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
ActiveCell.Characters(1, 2).PhoneticCharacters = "シツリョウ"
Range("G8").Select
Selection.Copy
Range("J15:J43").Select
ActiveSheet.Paste
ActiveWindow.SmallScroll ToRight:=-5
Range("A14").Select
ActiveWindow.SmallScroll Down:=18
ActiveWindow.SmallScroll ToRight:=10
Range("A14:O43").Select
Application.CutCopyMode = False
Selection.AutoFilter
ActiveWindow.SmallScroll ToRight:=3
Selection.AutoFilter Field:=9, Criteria1:="<>"
End Sub
|
|