I am receiving the above error at the highlighted point. I have a similar macro that functions properly but this one is causing me problems. As well if you have any suggestions to speed it up it would be much appreciated!!!
Sub EquityOrder()
'
' EqOrder Macro
'
'
Workbooks.Open Filename:= _
"K:\Retail Prodman\FlightDesk\Statistics\Source Data\OMS_SIT_EQOrders_" & _
Application.WorksheetFunction.Text(Date - 1, "yyyymmdd") & ".csv"
Application.ScreenUpdating = False
Dim Firstrow As Long
Dim Lastrow As Long
Dim Lrow As Long
Dim CalcMode As Long
Dim ViewMode As Long
With Application
CalcMode = .Calculation
.Calculation = xlCalculationManual
.ScreenUpdating = False
End With
Application.ScreenUpdating = False
'We use the ActiveSheet but you can replace this with
'Sheets("MySheet")if you want
With ActiveSheet
'We select the sheet so we can change the window view
.Select
'If you are in Page Break Preview Or Page Layout view go
'back to normal view, we do this for speed
ViewMode = ActiveWindow.View
ActiveWindow.View = xlNormalView
'Turn off Page Breaks, we do this for speed
.DisplayPageBreaks = False
'Set the first and last row to loop through
Firstrow = .UsedRange.Cells(1).Row
Lastrow = .UsedRange.Rows(.UsedRange.Rows.Count).Row
'We loop from Lastrow to Firstrow (bottom to top)
For Lrow = Lastrow To Firstrow Step -1
'We check the values in the A column in this example
With .Cells(Lrow, "AW")
If Not IsError(.Value) Then
If .Value <> "ATP" Then .EntireRow.Delete
End If
End With
Application.ScreenUpdating = False
ActiveWindow.View = ViewMode
With Application
.ScreenUpdating = False
.Calculation = CalcMode
End With
Dim rngData As Range, rngCell As Range
With ActiveSheet
Set rngData = .Range("C2:C1048575")
For Each rngCell In rngData
With rngCell
.Value = Val(.Value)
.NumberFormat = "0"
End With
Next Lrow
End With
Application.ScreenUpdating = False
Rows("1:1").Select
Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
Columns("C:C").Select
ActiveSheet.Range("$A$2:$BM$1048575").RemoveDuplicates Columns:=3, Header:= _
xlYes
Range("C1").Select
ActiveCell.FormulaR1C1 = "=COUNTIF(R[2]C:R[1048575]C,"">0"")"
Range("C1").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Columns("AK:AK").Select
Application.CutCopyMode = False
Selection.AutoFilter
ActiveSheet.Range("$AK$1:$AK$1048575").AutoFilter Field:=1, Criteria1:= _
"<>*fill*", Operator:=xlAnd
Rows("3:3").Select
Range("AI3").Activate
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Delete Shift:=xlUp
Selection.AutoFilter
Range("AK1").Select
ActiveCell.FormulaR1C1 = "=COUNTA(R[2]C:R[1048575]C)"
Range("AK2").Select
ActiveWindow.WindowState = xlNormal
ActiveWindow.WindowState = xlNormal
Range("C1").Select
Range("C1,AK1").Select
Range("AK1").Activate
Selection.Copy
ActiveWindow.WindowState = xlNormal
Windows("Standard Daily Stats.xlsm").Activate
ActiveWindow.WindowState = xlNormal
ActiveWindow.WindowState = xlNormal
With Sheet1.Range("G" & Rows.Count).End(xlUp).Offset(0)
.PasteSpecial Paste:=xlPasteValues
End With
End Sub
Bookmarks