fernandomtzm
New Member
- Joined
- Dec 9, 2020
- Messages
- 3
- Office Version
- 365
- Platform
- Windows
I have this code:
Dim sapconect, Manual As Boolean
Dim Carpeta As String
Dim Col As String
Dim Archivo As String
Dim ArchivoTrabajo As String
Dim Fecha As Date
Dim Criterios() As String
Dim ReporteSAP, TW As Workbook
Dim MacroTAB As Sheets
Dim UltimaLinea As Integer
Dim i As Integer
Sheets("Sheet1").Select
Cells.Select
Selection.AutoFilter
UltimaLinea = Cells(Rows.Count, "A").End(xlUp).Row
ActiveSheet.Range("$A$1:$O$" & UltimaLinea).AutoFilter Field:=4, Criteria1:="SA"
'Add filter to select date until today
Manual = TW.Sheets("SAP Report Sample").Range("D14")
If Manual Then Col = "D" Else Col = "E"
ReDim Criterios(0 To 7)
For i = 0 To 7
Fecha = TW.Sheets("SAP Report Sample").Range(Col & "9").Value + i
If Fecha >= TW.Sheets("SAP Report Sample").Range(Col & "10").Value Then Exit For
Criterios(i) = Format(Fecha, "MM/DD/YYYY")
ActiveSheet.Range("$A$1:$O$" & UltimaLinea).AutoFilter Field:=12, Operator:= _
xlFilterValues, Criteria2:=Array(2, Criterios(0), 2, Criterios(1), 2, Criterios(2), _
2, Criterios(3), 2, Criterios(4), 2, Criterios(5), 2, Criterios(6), 2, Criterios(7))
'Criterios are dates i want to filter( are 7 Criterios of 7 days of week)
And appear the msge: error "1004" - autofilter method of range class failed in this code:
ActiveSheet.Range("$A$1:$O$" & UltimaLinea).AutoFilter Field:=12, Operator:= _
xlFilterValues, Criteria2:=Array(2, Criterios(0), 2, Criterios(1), 2, Criterios(2), _
2, Criterios(3), 2, Criterios(4), 2, Criterios(5), 2, Criterios(6), 2, Criterios(7))
Dim sapconect, Manual As Boolean
Dim Carpeta As String
Dim Col As String
Dim Archivo As String
Dim ArchivoTrabajo As String
Dim Fecha As Date
Dim Criterios() As String
Dim ReporteSAP, TW As Workbook
Dim MacroTAB As Sheets
Dim UltimaLinea As Integer
Dim i As Integer
Sheets("Sheet1").Select
Cells.Select
Selection.AutoFilter
UltimaLinea = Cells(Rows.Count, "A").End(xlUp).Row
ActiveSheet.Range("$A$1:$O$" & UltimaLinea).AutoFilter Field:=4, Criteria1:="SA"
'Add filter to select date until today
Manual = TW.Sheets("SAP Report Sample").Range("D14")
If Manual Then Col = "D" Else Col = "E"
ReDim Criterios(0 To 7)
For i = 0 To 7
Fecha = TW.Sheets("SAP Report Sample").Range(Col & "9").Value + i
If Fecha >= TW.Sheets("SAP Report Sample").Range(Col & "10").Value Then Exit For
Criterios(i) = Format(Fecha, "MM/DD/YYYY")
ActiveSheet.Range("$A$1:$O$" & UltimaLinea).AutoFilter Field:=12, Operator:= _
xlFilterValues, Criteria2:=Array(2, Criterios(0), 2, Criterios(1), 2, Criterios(2), _
2, Criterios(3), 2, Criterios(4), 2, Criterios(5), 2, Criterios(6), 2, Criterios(7))
'Criterios are dates i want to filter( are 7 Criterios of 7 days of week)
And appear the msge: error "1004" - autofilter method of range class failed in this code:
ActiveSheet.Range("$A$1:$O$" & UltimaLinea).AutoFilter Field:=12, Operator:= _
xlFilterValues, Criteria2:=Array(2, Criterios(0), 2, Criterios(1), 2, Criterios(2), _
2, Criterios(3), 2, Criterios(4), 2, Criterios(5), 2, Criterios(6), 2, Criterios(7))