Ouverture d'un UserForm Impossible

K

kalif

Guest
Bonjour à tous et à toutes,

J'ai ce code:

Private Sub Worksheet_BeforeRightClick(ByVal Target As Excel.Range, Cancel As Boolean)
If Target.Column = 3 Then
UserForm1.Show
UserForm2.Show
Cancel = True
Exit Sub
End If
End Sub

Le UserForm1 s'ouvre bien, mais pas le 2, j'obtient:

Erreur d'exécution '9'
l'indice n'appartient pas à la sélection,

d'ou cela peut-il provenir?
Merci pour votre aide.

Bonne journée.
kalif
 
K

kalif

Guest
Re Bonjour

Voici le Code du UserForm2

Private Sub UserForm_Initialize()
Dim l As Integer
Dim plage As String
Dim cell As Range
Me.ListBox1.ColumnCount = 9
Me.ListBox1.ColumnHeads = True
Me.ListBox1.ColumnWidths = "10 pt;10pt;10pt;10pt;10pt;10pt;10pt;10pt;10pt"
l = Workbooks("C:\Chemin_Complet.xls").Sheets("Feuil1").End(xlUp).Row
plage = Workbooks("C:\Chemin_Complet.xls").Sheets("Feuil1").Range("a2:i" & l).Adress
ListBox1.RowSource = "Feuil1!" & plage
End Sub
 

Discussions similaires