Bonjour,
Après de multiple tentative je n'arrive pas à faire fonctionner mon code car la ligne : Cells(NumLigneVL, 8).Formula = FormuleVLC; La ligne débogue.
Sub NouvelOngletPiano()
Dim NomdelaFeuille As String
Dim NomVeille As String
Dim NomavantVeille As String
Dim Veille As String
Dim NumLigneSous As Integer
Dim FormuleSous As String
Dim NumLigneSous2 As Integer
Dim FormuleSous2 As String
Dim FormuleVLC As String
Dim NumLigneVL As Integer
Dim VL As Integer
Dim NomTableau As String
Dim ListObjects As String
Dim VeilleValue As Variant
'
Application.ScreenUpdating = False ' permet d'activer le mode turbo, évite les scintillements
Application.EnableEvents = False
Application.DisplayAlerts = False
'
Sheets(Sheets.Count).Copy After:=Sheets(Sheets.Count)
NomdelaFeuille = InputBox("Nom de l'onglet ?", "Nom de l'onglet")
Sheets(Sheets.Count).Name = NomdelaFeuille
'
Sheets(NomdelaFeuille).Activate
Veille = Sheets(Sheets.Count).Name
NomVeille = Sheets(Sheets.Count - 1).Name
NomavantVeille = Sheets(Sheets.Count - 2).Name
Range("H:H").Select
Selection.Replace What:=NomavantVeille, Replacement:=NomVeille, LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
'
'
' Souscriptions
NumLigneSous = Cells.Find(What:="Souscriptions", After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Row
Souscription = InputBox("Souscriptions ?", "Souscriptions")
'
FormuleSous = Cells(NumLigneSous, 8).Formula
FormuleSous = "=" & Souscription & "*'" & Veille & "'!VLC"
Cells(NumLigneSous, 8).Formula = FormuleSous
'
'
' Collecte du jour
NumLigneSous2 = Cells.Find(What:="Collecte jour", After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Row
'
FormuleSous2 = "=" & Souscription
Cells(NumLigneSous2, 8).Formula = FormuleSous2
'
' Récupération de collecte jour de l'onglet précédent pour calcul Nb de parts
VeilleValue = Sheets(NomVeille).Cells(NumLigneSous2, 8).Value
'
' Nb de parts
NumLigneVL = Cells.Find(What:="Nb de parts", After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Row
FormuleVLC = Cells(NumLigneVL, 8).Formula & " + " & IIf(VeilleValue < 0, -VeilleValue, VeilleValue)
Cells(NumLigneVL, 8).Formula = FormuleVLC
'
'
Application.EnableEvents = True
Application.DisplayAlerts = True
Application.ScreenUpdating = True ' permet de désactiver le mode turbo
'
With Sheets(NomdelaFeuille)
.ListObjects(1).Name = "Tableau" & NomdelaFeuille
End With
'
End Sub