Liens hypertexte dans LISTBOX
y
J'ai fais un fichier avec une liste de ville dans la colonne A et une liste de liens correspondant dans une colonne B.
J'ai fais comme une barre de recherche avec une liste... quand je tape le début de la ville voulu... cela me trouve le lien correspondant dans la listbox... seulement le liens n'est pas cliquable... J'ai trouvé des codes que j'ai adapté mais... je suis nul en VBA et en même temps j'en ai absolument besoin pour le boulot.... si quelqu'un pouvais m'aider...
J'ai fait un userform dans le code vb;
Voici mon code actuel :
code dans la Feuil1 :
Option Compare Text
Private Sub TextBox1_Change()
Application.ScreenUpdating = False
Range("A3:A1453").Interior.ColorIndex = 2
ListBox1.Clear
If TextBox1 <> "" Then
For ligne = 3 To 1453
If Cells(ligne, 1) Like "*" & TextBox1 & "*" Then
Cells(ligne, 1).Interior.ColorIndex = 43
ListBox1.AddItem Cells(ligne, 2)
End If
Next
End If
End SubCode dans le USERFORM :
Private Sub TextBox1_Change()
Application.ScreenUpdating = False
Range("A3:A1453").Interior.ColorIndex = 2
ListBox1.Clear
If TextBox1 <> "" Then
For ligne = 3 To 1453
If Cells(ligne, 1) Like "*" & TextBox1 & "*" Then
Cells(ligne, 1).Interior.ColorIndex = 43
ListBox1.AddItem Cells(ligne, 2)
End If
Next
End If
End Sub
Private Sub ListBox1_Click()
Dim Link As String, CurrentRecord As Long
CurrentRecord = CurrentRecord = Me.ListBox1.List(.ListIndex)
Link = rngData.Cells(CurrentRecord, 4).Hyperlinks(1).Address ' Adresse du lien
ThisWorkbook.FollowHyperlink Link ' Charge le lien
End Sub
With rng_Data
For r = 1 To .Rows.Count
' Splite les données vers lstFemale ou lstMale
If .Cells(r, ColumnNumber) = ConditionValue Then
Me.ListBox1.AddItem r ' N° d'enregistrement
For c = 1 To .Columns.Count: ListBox1.List(ListBox1.ListCount - 1, c) = .Cells(r, c): Next
End If
Next r
End WithModule 1 :
Option Explicit
Dim rng As Range, rngData As RangeMerci beaucoup d'avance