1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
| Sub RechercheDate()
Dim wsS1 As Worksheet 'Sheet1
Dim wsS2 As Worksheet 'Sheet3
Dim lastrow As Long
Dim lastrow2 As Long
Dim tempCriteria As String
Dim criter As String
Set wsS1 = Sheets("OPE")
Set wsS2 = Sheets("AFFICHAGE")
'hide dialogs
Application.ScreenUpdating = False
lastrow2 = wsS2.Range("A" & Rows.Count).End(xlUp).Row
wsS2.Range("A10:R" & lastrow2).Delete
tempCriteria = wsS2.Range("B4").Value + 1
criter = wsS2.Range("B4").Value + 2
'select sheet
'ActiveWorkbook.Sheets("OPE").Activate
'filter for records that have criteria in column defined by tempCriteria
wsS1.Cells.AutoFilter Field:=7, Criteria1:=tempCriteria, Operator:=xlOr, Criteria2:=criter
'Last row in A
lastrow = wsS1.Range("A" & Rows.Count).End(xlUp).Row
'Copy A:R and paste into A10
wsS1.Range("A1:R" & lastrow).Copy wsS2.Range("A10")
If wsS1.FilterMode = True Then
wsS1.AutoFilter.ShowAllData
End If
' select destination sheet
ActiveWorkbook.Sheets("AFFICHAGE").Activate
Application.ScreenUpdating = True
End Sub |
Partager