hyperlien dans liste, par macro

superbog

XLDnaute Occasionnel
Bonjour,

J'ai une macro récapitulative qui me permets sur une feuille de récapituler les données de certaines cellules des 160 feuilles "dossier".
Cette macro fonctionne parfaitement mais je voudrais que les les données de la colonne A (dossier) soient des hyperliens qui renvoient à la feuille concernée.

Ci joint un exemple de recap anonymisé

voici ma macro

Sub recap()
Dim Dl1 As Long ' dernière ligne
Dim sh As Worksheet
On Error GoTo recap_Error

With Sheets("recap")
.Cells.Delete
.Range("a1") = "dossier"
.Range("b1") = "nom du client"
.Range("c1") = "rappel factures"
.Range("d1") = "à facturer"
.Range("e1") = "solde dossier"
.Range("f1") = "crédit restant"
Range("A1:F1").Select
ActiveWindow.SmallScroll Down:=-3
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 65535
.TintAndShade = 0
.PatternTintAndShade = 0
End With

For Each sh In Worksheets
If IsNumeric(sh.Name) Then
Dl1 = .Range("A" & .Rows.Count).End(xlUp).Row + 1
If sh.Range("L18").Value > 0 Or sh.Range("K16").Value < 300 Then
.Range("a" & Dl1) = sh.Range("A2").Value
.Range("b" & Dl1) = sh.Range("B2").Value
.Range("c" & Dl1) = sh.Range("L15").Value
.Range("d" & Dl1) = sh.Range("L17").Value
.Range("e" & Dl1) = sh.Range("L18").Value
.Range("f" & Dl1) = sh.Range("K16").Value


End If

End If
Next sh
Selection.Columns.AutoFit
End With

On Error GoTo 0

MsgBox "mise à jour terminée"
Exit Sub

recap_Error:

MsgBox "erreur"
End Sub




merci d'avance pour votre aide
 

Pièces jointes

  • recaptest.xlsx
    10.9 KB · Affichages: 42

job75

XLDnaute Barbatruc
Re : hyperlien dans liste, par macro

Bonjour,

Code:
For Each sh In Worksheets
  If IsNumeric(sh.Name) Then
    If sh.Range("L18").Value > 0 Or sh.Range("K16").Value < 300 Then
      Dl1 = .Range("A" & .Rows.Count).End(xlUp).Row + 1
      .Range("a" & Dl1) = sh.Range("A2")
      .Hyperlinks.Add .Range("a" & Dl1), "", sh.Name & "!A2"
      .Range("b" & Dl1) = sh.Range("B2")
      .Range("c" & Dl1) = sh.Range("L15")
      .Range("d" & Dl1) = sh.Range("L17")
      .Range("e" & Dl1) = sh.Range("L18")
      .Range("f" & Dl1) = sh.Range("K16")
    End If
  End If
Next sh
Remarque : une macro entre balises
Code:
 sur le fil et un fichier [B].xlsm[/B] avec la macro dedans aurait été fair play...

A+
 

Statistiques des forums

Discussions
313 030
Messages
2 094 571
Membres
106 054
dernier inscrit
Mohajer