Hello le forum,
suite à une demande, je cale sur la façon de générer des TS avec un nombre de ligne déterminé par la variable nbl.
Merci à Jean-Eric pour la macro,
Public Sub CreateNewWorksheets()
Dim wb As Workbook, wsList As Worksheet, wsTemplate As Worksheet, ws As Worksheet
Dim modeCalc As XlCalculation
Dim I As Long, n As Long, nbl As Long
With Application
modeCalc = .Calculation
.Calculation = xlCalculationManual
.DisplayAlerts = False
.ScreenUpdating = False
End With
Set wb = ActiveWorkbook
Set wsList = wb.Worksheets("Office")
Set wsTemplate = wb.Worksheets("Modèle")
For Each ws In wb.Worksheets
Select Case ws.Name
Case "Office", "Modèle", "Legand", "Invoice", "Timesheet Record":
Case Else: ws.Delete
End Select
Next ws
Application.DisplayAlerts = True
n = wsList.Cells(Rows.Count, 2).End(xlUp).Row
For I = 3 To n
nbl = wsList.Cells(I, 3).Value
wsTemplate.Copy After:=wb.Worksheets(wb.Worksheets.Count)
Set ws = wb.Worksheets(wb.Worksheets.Count)
With ws
.Name = wsList.Cells(I, 2).Value
.Cells(6, 2).Value = ws.Name
.ListObjects(1).Name = "T_" & I - 2
End With
Next
With wsList
.Select
.Cells(1).Activate
End With
Application.Calculation = modeCalc
Set wb = Nothing
Set wsList = Nothing: Set wsTemplate = Nothing
End Sub
mais je n'arrive pas à borner le nb de ligne de chaque onglet.
Si quelqu'un a une soluce, j'achète.
Merci,
Cordialement