Re : copie mutiple de feuilles
Re,
A quoi correspondent :
[condition_retenue]
[bon_pour_accord_retenu]
etc ...
ce sont des cellules d'une autre feuille, que j'ai nommé ainsi et qui contiennent les valeurs à copier dans chacune des feuilles.
S'agissant de la création d'un programme de devis facturation, la cellule nommée condition retenue peut contenir des textes du style "paiement à la livraison", bien sur ces textes peuvent changer selon les désirs de l'utilisateur.
Merci de t'intéresser à mon problème.
En fait j'ai réussi à détourner en faisant un code qui me parait très lourd et que je voudrais simplifier, voici ci dessous l'extrait qui nous intéresse:
Sheets("DEVIS DE A à Z").Copy After:=Sheets(Sheets.Count)
Sheets("DEVIS DE A à Z (2)").Activate
Sheets("DEVIS DE A à Z (2)").Name = "Devis 1"
'---------------------------------
Sheets("Devis 1").Select
Sheets("Devis 1").Range("B58:B62").Select
With Selection
.HorizontalAlignment = xlLeft
.VerticalAlignment = xlTop
.WrapText = True
.Orientation = 0
.AddIndent = False
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = True
.Font.Bold = False
End With
Range("B58:B62").Value = [condition_retenue]
If [condition_retenue].Value <> "" Then
Range("B57").Value = "Conditions de paiement:"
Selection.Font.Bold = True
Else
Range("B57").Value = ""
End If
If [validité_retenue].Value <> "" Then
Range("B63").Value = "Validité du devis:" & " " & [validité_retenue]
End If
If [bon_pour_accord_retenu].Value <> "" Then
Range("D58:G62").Select
With Selection
.HorizontalAlignment = xlLeft
.VerticalAlignment = xlTop
.WrapText = True
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
.Font.Bold = False
End With
Selection.Merge
Range("D58").Value = [bon_pour_accord_retenu]
Else
Range("D58:G62").ClearContents
End If
'--------------------------
Range("G54").Formula = "=SUM(G23:G53)"
Range("G55").Formula = "=(G54*tva_retenue%)"
Range("G56").Formula = "=(G54+G55)"
Range("G54:G56").Select
With Selection
.HorizontalAlignment = xlRight
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
.Font.Bold = True
.NumberFormat = "0.00"
End With
Range("E54") = "Total HT"
Range("E55") = [taux_tva]
Range("E56") = "Total TTC"
Range("E54:E56").Select
With Selection
.HorizontalAlignment = xlLeft
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
.Font.Bold = True
End With
'-------------------------------
Sheets("DEVIS DE A à Z 2").Copy After:=Sheets("Devis 1")
Sheets("DEVIS DE A à Z 2 (2)").Activate
Sheets("DEVIS DE A à Z 2 (2)").Name = "Devis 2"
Sheets("Devis 2").Range("B58:B62").Select
With Selection
.HorizontalAlignment = xlLeft
.VerticalAlignment = xlTop
.WrapText = True
.Orientation = 0
.AddIndent = False
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = True
.Font.Bold = False
End With
'Range("inser").Select
Range("B58:B62").Value = [condition_retenue]
If [condition_retenue].Value <> "" Then
Range("B57").Value = "Conditions de paiement:"
Selection.Font.Bold = True
Else
Range("B57").Value = ""
End If
If [validité_retenue].Value <> "" Then
Range("B63").Value = "Validité du devis:" & " " & [validité_retenue]
End If
If [bon_pour_accord_retenu].Value <> "" Then
Range("D58:G62").Select
With Selection
.HorizontalAlignment = xlLeft
.VerticalAlignment = xlTop
.WrapText = True
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
.Font.Bold = False
End With
Selection.Merge
Range("D58").Value = [bon_pour_accord_retenu]
Else
Range("D58:G62").ClearContents
End If
'--------------------------
Range("G54").Formula = "=SUM(G10:G53)"
Range("G55").Formula = "=(G54*tva_retenue%)"
Range("G56").Formula = "=(G54+G55)"
Range("G54:G56").Select
With Selection
.HorizontalAlignment = xlRight
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
.Font.Bold = True
.NumberFormat = "0.00"
End With
Range("E54") = "Total HT"
Range("E55") = [taux_tva]
Range("E56") = "Total TTC"
Range("E54:E56").Select
With Selection
.HorizontalAlignment = xlLeft
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
.Font.Bold = True
End With
For i = 2 To 9
ActiveSheet.Name = "Devis " & i
Sheets("Devis 2").Copy After:=Sheets("devis " & i)
Next
ActiveSheet.Name = "Devis " & i
' Dim MesFeuilles(9)
'For i = 2 To 9
'MesFeuilles(i) = "Devis " & i + 1
'Next
Sheets("Devis 1").Activate
Sheets("Devis 1").Range("B15").Value = "Réf. Devis:" & " " & [nom_devis]
' Call conditions_page_2
Range("inser").Select
End If