This code worked last week and this week i open the file to find error messages.
The code goes through once every 4 or 5 tries then it gest stuck with the same formula on another page (have 12 of these worksheets jan-Dec).
Please help driving me crazy.
Private Sub Jan_Copy()
Application.ScreenUpdating = False
With Sheets("Data")
LastRow = .Range("C" & .Rows.Count).End(xlUp).Row
End With
Dim CD2 As Integer
CD2 = LastRow
Sheets("Jan").Select
Sheets("Jan").Cells(141, 1).Copy
Sheets("Jan").Range(Cells(143, 1), Cells(143 + CD2, 13)).PasteSpecial xlPasteFormulas
Application.CutCopyMode = False
Sheets("Jan").Range("B141").Select
Last = Cells(Rows.Count, "M").End(xlUp).Row
For i = Last To 1 Step -1
'this is where is gets stuck, the line below is highlighted
If (Cells(i, "M").Value) = "Incomplete DATA" Then
Cells(i, "A").EntireRow.Delete
End If
Next i
Range("A142:M142").Select
Selection.AutoFilter
ActiveWorkbook.Worksheets("Jan").AutoFilter.Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Jan").AutoFilter.Sort.SortFields.Add Key:=Range( _
"K142"), SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:= _
xlSortNormal
With ActiveWorkbook.Worksheets("Jan").AutoFilter.Sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Range("A142:M142").Select
Selection.AutoFilter
Call Feb_Copy
End Sub
Aucun commentaire:
Enregistrer un commentaire