excelのマクロが上手く動作しません
excel2013で、シートのレイアウトを整えるマクロを以下のように作成しました。
しかし、いざ他のシートで試すと、そのシートと同時に特定のシートにもなぜかマクロが実行されてしまいます。(恐らく作ったときに使っていたシート)
どうしたら今見ているシートだけにマクロを実行することができるでしょうか?
ActiveWindow.Zoom = 85
ActiveWindow.Zoom = 70
Columns("A:A").ColumnWidth = 10.13
Columns("A:A").ColumnWidth = 10.63
Columns("B:B").ColumnWidth = 6.63
Columns("D:D").ColumnWidth = 20
Columns("D:D").ColumnWidth = 23.75
Columns("D:D").ColumnWidth = 24.63
Columns("E:E").ColumnWidth = 10.38
Range("E1").Select
ActiveCell.FormulaR1C1 = "インボイス金額"
ActiveCell.Characters(7, 2).PhoneticCharacters = "キンガク"
Columns("F:F").Select
Selection.Delete Shift:=xlToLeft
Columns("G:G").Select
Selection.Delete Shift:=xlToLeft
Range("H9").Select
Columns("G:G").ColumnWidth = 11.38
Columns("I:K").Select
Selection.Delete Shift:=xlToLeft
Range("J9").Select
Columns("I:I").ColumnWidth = 15
Columns("J:J").ColumnWidth = 9.75
Columns("K:K").ColumnWidth = 9.5
Range("L2").Select
Columns("L:L").ColumnWidth = 5.5
Columns("O:O").Select
Selection.Delete Shift:=xlToLeft
Selection.ColumnWidth = 13.88
Columns("P:P").Select
Selection.Delete Shift:=xlToLeft
Selection.ColumnWidth = 12.13
Selection.ColumnWidth = 13.25
ActiveWindow.ScrollColumn = 2
ActiveWindow.ScrollColumn = 3
ActiveWindow.ScrollColumn = 4
ActiveWindow.ScrollColumn = 5
ActiveWindow.ScrollColumn = 6
ActiveWindow.ScrollColumn = 7
ActiveWindow.ScrollColumn = 8
ActiveWindow.ScrollColumn = 9
ActiveWindow.ScrollColumn = 10
ActiveWindow.ScrollColumn = 11
ActiveWindow.ScrollColumn = 12
Columns("Q:Q").Select
Selection.ColumnWidth = 5.5
Columns("S:S").Select
Selection.ColumnWidth = 6.75
Columns("T:T").ColumnWidth = 9.75
Columns("Q:T").Select
Range("T1").Activate
Selection.Style = "Comma [0]"
Columns("U:U").Select
Columns("V:V").ColumnWidth = 5.5
Columns("V:V").ColumnWidth = 6
Columns("W:Z").Select
Selection.Delete Shift:=xlToLeft
Columns("X:Z").Select
Selection.Delete Shift:=xlToLeft
Range("X10").Select
Columns("X:X").ColumnWidth = 12.25
Columns("X:X").ColumnWidth = 11.13
Columns("Y:Y").ColumnWidth = 6.75
Columns("Z:Z").ColumnWidth = 11.63
Columns("AA:AA").ColumnWidth = 6.75
Columns("AB:AB").Select
Selection.Delete Shift:=xlToLeft
Range("AB2").Select
Columns("AB:AB").ColumnWidth = 11
Columns("AD:AO").Select
Selection.Delete Shift:=xlToLeft
Range("AF14").Select
Columns("AD:AD").ColumnWidth = 11
Columns("AE:AE").Select
Selection.Delete Shift:=xlToLeft
Range("AG7").Select
Columns("AE:AE").ColumnWidth = 20.38
Columns("AF:AJ").Select
Selection.Delete Shift:=xlToLeft
ActiveWindow.ScrollColumn = 21
ActiveWindow.ScrollColumn = 1
Rows("2:2").Select
ActiveWindow.FreezePanes = True
Range("A2").Select
ActiveWorkbook.Worksheets("11").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("11").Sort.SortFields.Add Key:=Range("D2:D137"), _
SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
ActiveWorkbook.Worksheets("11").Sort.SortFields.Add Key:=Range("A2:A137"), _
SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("11").Sort
.SetRange Range("A1:AE137")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.Apply
End With
End Sub
よろしくお願い致します。