I created a macro to sort data and then open a specific workbook and then cut and past cells from that workbook to the one I just created. The problem is that it stops in the middle of the macro, right after it opens the specific workbook, when I run it in excel but it runs all the way through if I use Visual Basic Editor. Why wont it run all the way through?
I am also new to VBA and I tried searching already but I may not have the correct terminology down, sorry.
Here is the code:
Code
Columns("I:I").Select
Selection.NumberFormat = "[<=9999999]###-####;(###) ###-####"
Columns("D:D").Select
Selection.EntireColumn.Hidden = True
Cells.Select
Selection.Sort Key1:=Range("J2"), Order1:=xlAscending, Key2:=Range("B2") _
, Order2:=xlAscending, Header:=xlGuess, OrderCustom:=1, MatchCase:= _
False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal, DataOption2 _
:=xlSortNormal
Range("N1").Select
ChDir "S:\VALIDATIONS\Validation PM\Validation MISC\Validations Files"
Workbooks.Open Filename:= _
"S:\VALIDATIONS\Validation PM\Validation MISC\Validations Files\ADD_INS.XLS"
Sheets("Notation Cells (Shaded)").Select
Selection.Copy
ActiveWindow.WindowState = xlMinimized
ActiveSheet.Paste
Range("N4:S4").Select
Application.CutCopyMode = False
Selection.AutoFill Destination:=Range("N4:S239"), Type:=xlFillDefault
Range("N4:S239").Select
ActiveWindow.ScrollRow = 217
ActiveWindow.ScrollRow = 15
ActiveWindow.ScrollRow = 13
ActiveWindow.ScrollRow = 12
ActiveWindow.ScrollRow = 11
ActiveWindow.ScrollRow = 10
ActiveWindow.ScrollRow = 9
ActiveWindow.ScrollRow = 8
ActiveWindow.ScrollRow = 7
ActiveWindow.ScrollRow = 6
ActiveWindow.ScrollRow = 5
ActiveWindow.ScrollRow = 4
ActiveWindow.ScrollRow = 3
ActiveWindow.ScrollRow = 2
ActiveWindow.ScrollRow = 1
Rows("1:1").Select
Range("G1").Activate
Selection.AutoFilter
Rows("2:2").Select
ActiveWindow.FreezePanes = True
End Sub
Display More