I'm running the following macro that selects a range and sorts it z->a. Then, the macro will do some find and delete stuff. However, the macro gets to the sort phase and then loops back up to the beginning instead of continuing. I used the macro recorded insted of typing in the code. What's the problem?
Sub temp()
ActiveWindow.ScrollRow = 1
Range("D9"
.Select
Selection.Sort Key1:=Range("D9"
, Order1:=xlDescending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False,
' This is where the code breaks and then wants to loop back to the first line. The macro will not continue to the code below
Orientation:=xlTopToBottom
Columns("B:B"
.Select
Range("B8"
.Activate
Selection.FindNext(After:=ActiveCell).Activate
ActiveCell.Offset(-1, -1).Range("A1"
.Select
Range(Selection, Selection.End(xlUp)).Select
Selection.Copy
Workbooks.Add
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "zip"
Range("A1"
.Select
Selection.CurrentRegion.Select
ActiveWorkbook.Names.Add Name:="database", RefersToR1C1:= _
"=Sheet1!R1C1:R112C1"
ActiveWorkbook.SaveAs Filename:="D:\pcode\z.dbf", FileFormat:=xlDBF4, _
CreateBackup:=False
End Sub
Chandler
I ran over my dogma with karma!
Sub temp()
ActiveWindow.ScrollRow = 1
Range("D9"
Selection.Sort Key1:=Range("D9"
OrderCustom:=1, MatchCase:=False,
' This is where the code breaks and then wants to loop back to the first line. The macro will not continue to the code below
Orientation:=xlTopToBottom
Columns("B:B"
Range("B8"
Selection.FindNext(After:=ActiveCell).Activate
ActiveCell.Offset(-1, -1).Range("A1"
Range(Selection, Selection.End(xlUp)).Select
Selection.Copy
Workbooks.Add
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "zip"
Range("A1"
Selection.CurrentRegion.Select
ActiveWorkbook.Names.Add Name:="database", RefersToR1C1:= _
"=Sheet1!R1C1:R112C1"
ActiveWorkbook.SaveAs Filename:="D:\pcode\z.dbf", FileFormat:=xlDBF4, _
CreateBackup:=False
End Sub
Chandler
I ran over my dogma with karma!