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 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128
| Sub genere_onglets_fournisseur()
On Error GoTo errorHandler:
Dim x As Integer
Dim LettreVoulue As String
LettreVoulue = TrouveLettreColonne([fournisseur])
Dim nom_fournisseur As Variant
Dim entete As Range
Dim start As Single
Dim finish As Single
start = Timer
Application.ScreenUpdating = False
'détruire onglet si ré-exécution de la macro
detruire_onglet
'nettoie le nom des fournisseurs provenant du LAC afin d'éviter d'avoir 2 onglets
Range(LettreVoulue & 2, LettreVoulue & LastLignUsedInSheet("R_MoulinetteAValider")).Select
nettoyerseul
'création des feuilles selon le nom des fournisseur
For Each nom_fournisseur In Feuil1.Range(LettreVoulue & 2, LettreVoulue & LastLignUsedInColumn(LettreVoulue))
x = x + 1
If IsNumeric(nom_fournisseur) = False And IsEmpty(nom_fournisseur) = False Then
If Cells(x + 1, [valider_x].Column) = "x" Or Cells(x + 1, [valider_x].Column) = "X" Then
If sheetExists(nom_fournisseur.Value) = True Then
Else
Sheets.Add.Name = nom_fournisseur
Feuil1.[entete].Copy Sheets(nom_fournisseur.Value).Range("a1")
ActiveSheet.Shapes.Range(Array("Button 1")).Delete
Range("q1").Copy Range("q1:t1")
Range("r1").Value = "Description du fournisseur"
Range("s1").Value = "Reponse du fournisseur"
Range("t1").Value = "Lien internet ou catalogue du fournisseur"
Columns("a:C").ColumnWidth = 6.11
Columns("D").ColumnWidth = 8.33
Columns("E").ColumnWidth = 15.78
Columns("F").ColumnWidth = 11.89
Columns("G").ColumnWidth = 15.78
Columns("H").ColumnWidth = 40
Columns("I:P").ColumnWidth = 15.78
Columns("Q").ColumnWidth = 11.89
Columns("R:U").ColumnWidth = 40
Range("a2").Activate
End If
'on copie les données dans la feuille correspondantes
Feuil1.Cells(x + 1, [ID].Column).Copy Sheets(nom_fournisseur.Value).Cells(x + 1, 1)
Feuil1.Cells(x + 1, [seq].Column).Copy Sheets(nom_fournisseur.Value).Cells(x + 1, 2)
Feuil1.Cells(x + 1, [pair_impair].Column).Copy Sheets(nom_fournisseur.Value).Cells(x + 1, 3)
Feuil1.Cells(x + 1, [etab].Column).Copy Sheets(nom_fournisseur.Value).Cells(x + 1, 4)
Feuil1.Cells(x + 1, [acronyme_etab].Column).Copy Sheets(nom_fournisseur.Value).Cells(x + 1, 5)
Feuil1.Cells(x + 1, [item_etab_moulinette].Column).Copy Sheets(nom_fournisseur.Value).Cells(x + 1, 6)
Feuil1.Cells(x + 1, [item_etab].Column).Copy Sheets(nom_fournisseur.Value).Cells(x + 1, 7)
Feuil1.Cells(x + 1, [descr_etab].Column).Copy Sheets(nom_fournisseur.Value).Cells(x + 1, 8)
Feuil1.Cells(x + 1, [couleur_etab].Column).Copy Sheets(nom_fournisseur.Value).Cells(x + 1, 9)
Feuil1.Cells(x + 1, [fourn_etab].Column).Copy Sheets(nom_fournisseur.Value).Cells(x + 1, 10)
Feuil1.Cells(x + 1, [fournisseur].Column).Copy Sheets(nom_fournisseur.Value).Cells(x + 1, 11)
Feuil1.Cells(x + 1, [marque_etab].Column).Copy Sheets(nom_fournisseur.Value).Cells(x + 1, 12)
Feuil1.Cells(x + 1, [cat_etab].Column).Copy Sheets(nom_fournisseur.Value).Cells(x + 1, 13)
Feuil1.Cells(x + 1, [format_contrat].Column).Copy Sheets(nom_fournisseur.Value).Cells(x + 1, 14)
Feuil1.Cells(x + 1, [qte_an].Column).Copy Sheets(nom_fournisseur.Value).Cells(x + 1, 15)
Feuil1.Cells(x + 1, [prix_contrat].Column).Copy Sheets(nom_fournisseur.Value).Cells(x + 1, 16)
Feuil1.Cells(x + 1, [valider_x].Column).Copy Sheets(nom_fournisseur.Value).Cells(x + 1, 17)
Feuil1.Cells(x + 1, [commentaire].Column).Copy Sheets(nom_fournisseur.Value).Cells(x + 1, 18)
'on supprime les lignes vides si bien sur les feuilles ont été créés
Sheets(nom_fournisseur.Value).Select
Range("A2").EntireRow.Insert
Sheets(nom_fournisseur.Value).Range("b1:B" & LastLignUsedInColumn("B")).SpecialCells(xlCellTypeBlanks).EntireRow.Delete
End If
Feuil1.Select
Else
MsgBox "Le nom du fournisseur suivant est numérique : " & nom_fournisseur & " SVP corriger et re-cliquer sur généré"
Exit Sub
End If
Next nom_fournisseur
finish = Timer
MsgBox "durée du traitement: " & finish - start & " secondes"
Exit Sub
errorHandler:
MsgBox "Subroutine exécuté dans le mauvais fichier !!!", vbCritical
End Sub |
Partager