Re: J'ai honte -mais un moment de honte est vite passé
Voilà comment je m'y serais pris pour renvoyer automatiquement des noms de feuilles incrémentés :
Option Explicit
'Ti 29/07/03
Private Function NouveauNom(NomFeuille As String) As String
Dim Ws As Worksheet, Nom As String
Dim Numero As Byte, Indice As Byte, Max As Byte
For Each Ws In ThisWorkbook.Worksheets
Indice = 0
If InStr(1, Ws.Name, NomFeuille, vbTextCompare) > 0 Then
Do While IsNumeric(Right(Ws.Name, Indice + 1))
Indice = Indice + 1
Loop
If Indice > 0 Then Numero = Right(Ws.Name, Indice)
If Numero > Max Then Max = Numero
End If
Next Ws
NouveauNom = NomFeuille & Max + 1
End Function
Sub AjoutLg()
Dim Ws As Worksheet
Set Ws = ThisWorkbook.Sheets.Add
With Ws
.Name = NouveauNom("Lg")
Sheets("Modèle Lg").Cells.Copy .Range("A1")
End With
End Sub
Sub AjoutCalcul()
Dim Ws As Worksheet
Set Ws = ThisWorkbook.Sheets.Add
With Ws
.Name = NouveauNom("Calcul")
'Sheets("Modèle Lg").Cells.Copy .Range("A1")
'Sheets("Lg." & (P + 1)).Select
End With
End Sub