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
| Private Sub CommandButton1_Click()
Application.ScreenUpdating = False
'enregistre le titre de la page en cours
nom_feuille = ActiveSheet.Name
Dim B1 As String
Dim B2 As String
'definit B1 comme le texte du bouton 1
ActiveSheet.Shapes.Range(Array("Button 1")).Select
B1 = Selection.Characters.Text
'definit B2 avec le titre actuel
Range("B2:D2").Select
B2 = ActiveCell.FormulaR1C1
'defini le titre de la categorie
Dim vTitre As String
vTitre = TextBox1
'copie la page model
Worksheets("Model.3").Copy After:=Worksheets("Model.3")
'nomme la nouvelle page model avec le titre de la catégorie et le titre dans le quel elle est crée
Worksheets("Model.3 (2)").Name = vTitre & " " & B2
Dim newtitre As String
newtitre = vTitre & " " & B2
'ajoute un bouton et le nomme "B1"
Sheets(vTitre & " " & B2).Buttons.Add(0, 0.75, 60, 33).Select
Selection.Characters.Text = B1
With Selection.Font
.Name = "Calibri"
.FontStyle = "Gras"
.Size = 14
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.Color = -16777216
End With
Selection.OnAction = "Bouton3_" & B1
'ajoute B2 etle définit
Sheets(vTitre & " " & B2).Buttons.Add(60, 0, 60, 15.75).Select
Selection.Characters.Text = B2
With Selection.Font
.Name = "Calibri"
.FontStyle = "Gras"
.Size = 11
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.Color = -16777216
End With
Selection.OnAction = "Bouton3_" & B2
'définit titre de page
Range("B2:D2").Select
Selection.Font.Bold = True
With Selection.Font
.Name = "Calibri"
.Size = 14
End With
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Selection.Merge
ActiveCell.FormulaR1C1 = vTitre
'cherche la colone vide pour lui ajouter le bouton de cat
Worksheets(nom_feuille).Activate
Dim Col As Integer
Col = Rows(5).Find("*", , , , xlByRows, xlPrevious).Column + 1
Cells(5, Col) = "ok"
Cells(6, Col).Select
ActiveCell.FormulaR1C1 = "='" & newtitre & "'!RC2"
Selection.AutoFill Destination:=Range(Cells(6, Col), Cells(19, Col)), Type:=xlFillDefault
Col = (Col - 1) * 60
ActiveSheet.Buttons.Add(Col, 64.5, 60, 16.5).Select
Selection.Characters.Text = vTitre & " " & B2
Selection.OnAction = "macro_test"
UserForm1.Hide
End Sub |
Partager