J'aimerais ajouter un bouton qui m'amène à la feuille que je viens de créer. Mais je n'y arrive pas....
J'ai pourtant activé ma feuille sur laquelle le bouton doit apparaître et testé beaucoup de moyen différent pour activer la cellule où j'aimerais que mon bouton se situ.
Voilà mon code avec en gras la partie délicate (je pense)....
Merci de votre aide!
Option Explicit
Private Sub Label1_Click()
End Sub
Private Sub CommandButton1_Click()
' NewGRDF incorporer une nouvelle famille ' Selectionner 2 lignes après la derniere zone de texte dans la colonne B
Set Ws = Sheets.Add Ws.Move After:=Worksheets(truc + 1)
'nom deja pris? A FAIRE
Ws.Name = TextBox1
'Insertion du texte dans la feuille
Range("a1") = "Dernière mise à jour:" Range("b8") = TextBox1 Range("h1") = "Util. :" Range("c1") = Date
'Inserer un bouton ramenant à la feuille précédente.
'Création du bouton
Dim btnprec As OLEObject
Set btnprec = Ws.OLEObjects.Add("Forms.CommandButton.1") With btnprec .Name = "btnprec" .Left = 50 'position horizontale par rapport au bord gauche de la feuille .Top = 50 'position verticale par rapport au bord haut de la feuille .Width = 30 'largeur .Height = 17 'hauteur .Object.Caption = "<--" End With
With ActiveWorkbook.VBProject.VBComponents(ActiveSheet.CodeName).CodeModule NextLine = .CountOfLines + 1 .insertlines NextLine, Code End With
'Insérer un bouton créant une sous famille A FAIRE utiliser une boucle?
'Ajouter un bouton sur la feuille d'accueil pour pouvoir atteindre la NewGRDF
Sheets("acceuil").Activate
'Ajout du bouton
Dim btnGRDF As OLEObject
Range("D23").Activate
Set btnGRDF = Ws.OLEObjects.Add("Forms.CommandButton.1") With btnGRDF .Name = "btnGRDF" .Left = ActiveCell.Left 'position horizontale par rapport au bord gauche de la feuille .Top = ActiveCell.Top 'position verticale par rapport au bord haut de la feuille .Width = ActiveCell.Width 'largeur .Height = ActiveCell.Height 'hauteur .Object.Caption = "Go" End With
'Création de la commande
Dim Text As String
btnGRDF.Row.Activate Text = Cells("activerow", 2).Name