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
| Option Explicit
Sub Sheet_equipement_generation()
Dim i As Long, z As Long
Dim SourceFile As String, DestinationFile As String
SourceFile = ThisWorkbook.Path & "\1-MM_TEMPLATE\SPL-E_Template_Reference.xlsx"
i = 4
Application.ScreenUpdating = False
With ThisWorkbook.Worksheets("Input")
While Not IsEmpty(.Cells(i, 1))
If .Cells(i, 1).Value = "1" Then 'Only Generate Equipment with "1" in column A
DestinationFile = ThisWorkbook.Path & "\2-GENERATED_SPLE\" & Range("AD" & i) & ".xlsx"
FileCopy SourceFile, DestinationFile
Workbooks.Open DestinationFile
'==== remplir feuille n°1, partie titres
Sheets("SPL-E_Sh.1").Select '<--- select
Range("B7") = .Range("AG" & i) ' Main Function/Main Tag
Range("B9") = .Range("AQ" & i) ' Main Function/Main Tag Description
'... et ainsi de suite
z = 0
Do
'==== remplir feuille n°1, partie données
Sheets("SPL-E_Sh.1").Select '<--- select
Range("A16").Offset(z, 0) = .Range("O" & i)
Range("B16").Offset(z, 0) = .Range("P" & i)
'... et ainsi de suite
'==== remplir feuille n°2, partie données
Sheets("SPL-E_Sh.2 _ Eqt-List").Select
Range("U14").Offset(z, 0) = .Range("AF" & i) 'PO Number
Range("B14").Offset(z, 0) = .Range("AR" & i) 'Location
'... et ainsi de suite
i = i + 1
z = z + 1
Loop Until .Cells(i, 1) = 1 Or IsEmpty(.Cells(i, 1))
ActiveWorkbook.Close SaveChanges:=True
End If
Wend
End With
MsgBox (" SPLE Generated !")
End Sub |
Partager