So I'm trying to essentially filter my data set in a certain way. There may be a better way of doing this and I may be over complicating things, so if that's the case, feel free to chime in any ideas. So, essentially I'm filtering my data set. However based on that filter, I will only take some specific data based on a criteria. I will therefore be hiding the data that don't fit that criteria, which is shown here:
If Sheet1.Cells(i, 11) = StandardW And Sheet1.Cells(i, 32) > Date1 Then
Rows("i:i").Select
Selection.EntireRow.Hidden = True
I will then be copying the first column of my data set and pasting it elsewhere to use it afterwards. However, for some reason, I keep getting a "Run time error 6 overflow error message." Not sure why. Any ideas? As mentioned above, maybe there's a simpler way of arranging my data around that I haven't thought about. If that's the case, feel free to chip in.
Thanks!
Sub CopyingCodesCALG()
Dim Standard As Date
Dim i As Integer
Dim lastrow As Long
lastrow = ActiveSheet.Cells(Rows.count, "B").End(xlUp).Row
Standard = Date - 3
StandardW = Date - 2
Date1 = Date - 1
'this utilizes Activesheets, may have to find a workaround for this depending on the data. Maybe add it to the MF and use thisworkbook?
Rows("1:1").Select
Selection.AutoFilter
ActiveSheet.UsedRange.AutoFilter Field:=3, Criteria1:= _
"Livraison"
ActiveSheet.UsedRange.AutoFilter Field:=11, Operator:= _
xlFilterValues, Criteria2:=Array(2, Standard, 2, StandardW)
ActiveSheet.UsedRange.AutoFilter Field:=25, Criteria1:= _
"=Return to warehouse", Operator:=xlOr, Criteria2:="="
ActiveSheet.UsedRange.AutoFilter Field:=17, Criteria1:=Array( _
"Data received", "Data received - shipment not received", "Loaded", "Loading", _
"Optimized", "Received", "="), Operator:=xlFilterValues
ActiveSheet.UsedRange.AutoFilter Field:=34, Criteria1:="="
ActiveSheet.UsedRange.AutoFilter Field:=2, Criteria1:= _
"INTLCM-CALG"
i = 2
For i = 2 To lastrow
If Sheet1.Cells(i, 11) = StandardW And Sheet1.Cells(i, 32) > Date1 Then
Rows("i:i").Select
Selection.EntireRow.Hidden = True
End If
Next i
ActiveSheet.AutoFilter.Range.Offset(1).SpecialCells(xlCellTypeVisible).Cells(1, 1).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
End Sub