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 47 48 49 50 51 52
| Sub concatene()
Dim infolog, final As Workbook
Dim Nomfichier As String
Dim cpt, i As Double
dateJ = Date
dateYYYY = Right(dateJ, 4)
dateMM = Left(Right(dateJ, 7), 2)
dateDD = Left(dateJ, 2)
dateFic = dateYYYY & dateMM & dateDD
cpt = 1
Workbooks.Add
ActiveWorkbook.SaveAs Filename:= _
"C:\Users\kguesmia\Documents\Alerte CASSE appro\Risque CASSE au " & dateFic & ".xlsx" _
, FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False
Application.DisplayAlerts = True
Set final = Workbooks.Open(Filename:="C:\Users\kguesmia\Documents\Alerte CASSE appro\Risque CASSE au " & dateFic & ".xlsx")
Set infolog = Workbooks.Open(Filename:="C:\Users\kguesmia\Documents\Alerte CASSE appro\Donnees\Liste4_" & dateFic & " .xls")
Application.Wait Time + TimeSerial(0, 0, 3) 'attendre 3s
infolog.Sheets(1).UsedRange.Copy final.Sheets(1).Range("A" & cpt)
Application.Wait Time + TimeSerial(0, 0, 3) 'attendre 3s
cpt = final.Sheets(1).Range("A" & Rows.Count).End(xlUp).Row
i = 5
Do While i <> 95
Nomfichier = Dir("C:\Users\kguesmia\Documents\Alerte CASSE appro\Donnees\Liste" & i & "_" & dateFic & " .xls")
If Nomfichier <> "" Then
Set infolog = Workbooks.Open(Filename:="C:\Users\kguesmia\Documents\Alerte CASSE appro\Donnees\Liste" & i & "_" & dateFic & " .xls")
Application.Wait Time + TimeSerial(0, 0, 3) 'attendre 3s
' Application.CutCopyMode = False:
infolog.Sheets(1).Rows(1).Delete
infolog.Sheets(1).UsedRange.Copy final.Sheets(1).Range("A" & cpt + 1)
Application.Wait Time + TimeSerial(0, 0, 3) 'attendre 3s
infolog.Sheets(1).UsedRange.Copy: Application.CutCopyMode = False
infolog.Close SaveChanges:=False
cpt = final.Sheets(1).Range("A" & Rows.Count).End(xlUp).Row
End If
i = i + 1
Loop |
Partager