Ceci est une page optimisée pour les mobiles. Cliquez sur ce texte pour afficher la vraie page.

macro : liste lien hypertexte des onglets

  • Initiateur de la discussion Initiateur de la discussion tryssa
  • Date de début Date de début

Boostez vos compétences Excel avec notre communauté !

Rejoignez Excel Downloads, le rendez-vous des passionnés où l'entraide fait la force. Apprenez, échangez, progressez – et tout ça gratuitement ! 👉 Inscrivez-vous maintenant !

tryssa

XLDnaute Nouveau
Bonjour,

J'aimerais créer une macro qui :

1) créer un nouvel onglet
2) le positionne en 1er
3) le nomme "contenu"
4) y créé la liste avec lien hypertexte de tous les onglets présents dans le fichier

Voici où j'en suis :
Sub contenu()
For Each sh In Sheets
i = i + 1
Cells(i, 1) = sh.Name
Next sh
End Sub

Merci pour votre aide !
 
Re : macro : liste lien hypertexte des onglets

bonjour tryssa,

voici une solution :

Code:
Sub test()
Dim curSht As Worksheet
With ThisWorkbook.Sheets.Add(before:=ThisWorkbook.Sheets(1))
    For Each curSht In ThisWorkbook.Sheets
        If .Name <> curSht.Name Then .Hyperlinks.Add Anchor:=.Cells(.Rows.Count, 1).End(xlUp).Offset(1, 0), Address:="", SubAddress:= _
        curSht.Name & "!A1", TextToDisplay:=curSht.Name
    Next
End With
End Sub

a+
 
Re : macro : liste lien hypertexte des onglets

En partant de la réponse de mromain, voici ma macro finale:

Sub Page_de_garde()
ActiveWorkbook.Sheets.Add before:=ThisWorkbook.Sheets(1)
Dim i As Integer
'
For i = 1 To Sheets.Count
Cells(i, 1).Select
ActiveSheet.Hyperlinks.Add Anchor:=Selection, Address:="", SubAddress:= _
Sheets(i).Name & "!A1", TextToDisplay:="vers " & Sheets(i).Name
Next i
Rows("1:4").Select
Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
Range("A1").Select
ActiveCell.FormulaR1C1 = "Contenu du fichier"
Range("A2").Select
ActiveCell.FormulaR1C1 = ActiveWorkbook.Name
Range("A4").Select
ActiveCell.FormulaR1C1 = "Onglet"
Range("B4").Select
ActiveCell.FormulaR1C1 = "Descriptif"
Range("A1:B1").Select
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Selection.Merge
Range("A2:B2").Select
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Selection.Merge
Range("F5").Select
ActiveWindow.DisplayGridlines = False
Range("A1:B2").Select
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 65535
.TintAndShade = 0
.PatternTintAndShade = 0
End With
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorAccent1
.TintAndShade = 0.799981688894314
.PatternTintAndShade = 0
End With
Range("A4:B4").Select
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorAccent1
.TintAndShade = 0.799981688894314
.PatternTintAndShade = 0
End With
Selection.Font.Bold = True
Range("A1:B1").Select
Selection.Font.Bold = True
End Sub
 
- Navigue sans publicité
- Accède à Cléa, notre assistante IA experte Excel... et pas que...
- Profite de fonctionnalités exclusives
Ton soutien permet à Excel Downloads de rester 100% gratuit et de continuer à rassembler les passionnés d'Excel.
Je deviens Supporter XLD

Discussions similaires

Réponses
2
Affichages
203
Réponses
4
Affichages
179
Les cookies sont requis pour utiliser ce site. Vous devez les accepter pour continuer à utiliser le site. En savoir plus…