Sub Macro1()
Dim i As Integer
Dim j As Integer
Dim Ps As Workbook
Dim PL As Workbook
Dim Path As String
Sheet1.Cells.Clear
Path = "z:PONTECCHIO-MARCONI\_Technical_DepartementManutenzione-MeccaniciP&SP&S20168)PS agosto2016 .xlsm"
Set Ps = Workbooks.Open(Path)
Ps.Sheets(" P&S").Activate
i = 1
j = 1
Do While Cells(i, 5) <> "" Or Cells(i, 8) <> 0
If (i = 1 And j = 1) Or (Cells(i, 13) <= Date And Cells(i, 14) >= Date) Then
ThisWorkbook.Sheets(1).Cells(j, 1) = Cells(i, 5)
ThisWorkbook.Sheets(1).Cells(j, 2) = Cells(i, 8)
ThisWorkbook.Sheets(1).Cells(j, 3) = Cells(i, 9)
ThisWorkbook.Sheets(1).Cells(j, 4) = Cells(i, 11)
ThisWorkbook.Sheets(1).Cells(j, 5) = Cells(i, 13)
ThisWorkbook.Sheets(1).Cells(j, 6) = Cells(i, 14)
ThisWorkbook.Sheets(1).Cells(j, 5).NumberFormat = "m/d/yyyy"
ThisWorkbook.Sheets(1).Cells(j, 6).NumberFormat = "m/d/yyyy"
ThisWorkbook.Sheets(1).Cells(j, 7) = Cells(i, 16)
ThisWorkbook.Sheets(1).Cells(j, 8) = Cells(i, 18)
ThisWorkbook.Sheets(1).Cells(j, 9) = "MTZ"
ThisWorkbook.Sheets(1).Cells(1, 9) = "MTZ-MTG"
j = j + 1
End If
i = i + 1
Loop
Ps.Close
Path = "C:UsersGiustiS1Desktopmtg_prova.xlsx"
Set PL = Workbooks.Open(Path)
'PL.Sheets("NPL").Activate
i = 1
j = 1
Do While Cells(i, 2) <> "" Or Cells(i, 1) <> 0
If (Cells(i, 10) = Date) Then
ThisWorkbook.Sheets(1).Cells(j, 1) = Cells(i, 7)
ThisWorkbook.Sheets(1).Cells(j, 2) = Cells(i, 3)
ThisWorkbook.Sheets(1).Cells(j, 3) = Cells(i, 9)
ThisWorkbook.Sheets(1).Cells(j, 4) = Cells(i, 5)
ThisWorkbook.Sheets(1).Cells(j, 5) = Cells(i, 1)
ThisWorkbook.Sheets(1).Cells(j, 6) = Cells(i, 10)
ThisWorkbook.Sheets(1).Cells(j, 5).NumberFormat = "m/d/yyyy"
ThisWorkbook.Sheets(1).Cells(j, 6).NumberFormat = "m/d/yyyy"
ThisWorkbook.Sheets(1).Cells(j, 7) = Cells(i, 4)
ThisWorkbook.Sheets(1).Cells(j, 8) = Cells(i, 2)
ThisWorkbook.Sheets(1).Cells(j, 9) = "MTG"
j = j + 1
End If
i = i + 1
Loop
PL.Close
End Sub
|