Afficher un ShapeRange

Résolu
cs_JMO Messages postés 1854 Date d'inscription jeudi 23 mai 2002 Statut Membre Dernière intervention 24 juin 2018 - 4 mai 2008 à 12:19
cs_JMO Messages postés 1854 Date d'inscription jeudi 23 mai 2002 Statut Membre Dernière intervention 24 juin 2018 - 4 mai 2008 à 16:10
 Bonjour à tous,

Tout d'abord, merci d'avance pour votre indulgence.
Je découvre VBE (Excel 2003).

Ouverture fichier Excel
Private Sub Workbook_Open()
   'A l'ouverture du fichier, on masque Excel
    Application.Visible = False
   'Ouverture UserForm1
    UserForm1.Show
End Sub

Dans UserForm1, j'ai placé un ListBox1 (liste déroulante avec scroolbar) et un TextBox1 (multi-ligne et locked=true).

Déclaration ListBox1
RowSource = Feuil1!A2:C1400 (+ColumnWidths)
Les données des 3 colonnes s'affichent bien.

Private Sub ListBox1_Click()
Label1.Caption = String(20, "-") & ListBox1.Column(2) & " " & String(20, "-")TextBox1.Text "ListBox1.ListIndex " & ListBox1.ListIndex
TextBox1.Text = TextBox1.Text & vbCrLf & ListBox1.Column(1) & vbCrLf & ListBox1.Column(0)
End Sub

Question:
Comment afficher, dans TextBox1, le commentaire (s'il existe)
de la cellule ["C" & ListBox1.ListIndex+2]  de Feuil1 ???

jean-marc

4 réponses

cs_MPi Messages postés 3877 Date d'inscription mardi 19 mars 2002 Statut Membre Dernière intervention 17 août 2018 23
4 mai 2008 à 14:21
Ceci peut-être ?
Range("C" & ListBox1.ListIndex + 2).Comment.Text

En fait, je ne suis pas certain du "+2"
Est-ce que c'est la deuxième ligne sous la ligne choisie ?
Ou est-ce la troisième colonne de la ligne sélectionnée ?

Dans le deuxième cas, il faut utiliser la méthode .List(Ligne, Colonne)

MPi²
Pour ceux qui programment sous Office, n'oubliez pas qu'il existe un forum dédié à ces applications VBA....... ICI
3
cs_MPi Messages postés 3877 Date d'inscription mardi 19 mars 2002 Statut Membre Dernière intervention 17 août 2018 23
4 mai 2008 à 15:54
Comme ceci, je pense

    If Not Range("A1").Comment Is Nothing Then
        MsgBox Range("A1").Comment.Text
    Else
        MsgBox "Pas de commentaire"
    End If

MPi²
Pour ceux qui programment sous Office, n'oubliez pas qu'il existe un forum dédié à ces applications VBA....... ICI
3
cs_JMO Messages postés 1854 Date d'inscription jeudi 23 mai 2002 Statut Membre Dernière intervention 24 juin 2018 27
4 mai 2008 à 15:14
Re,

Range("C" & ListBox1.ListIndex + 2).Comment.Text  me renvoie le bon commentaire.
Header dans la feuil1 + ColumnHeads=True + ListIndex débutant à 0, je vais corriger cela.

Petit souci, comment tester la non existence d'un commentaire ?

jean-marc
0
cs_JMO Messages postés 1854 Date d'inscription jeudi 23 mai 2002 Statut Membre Dernière intervention 24 juin 2018 27
4 mai 2008 à 16:10
Merci MPi,

Je continue à potasser les tutoriels, et ne manquerai pas de poser d'autres questions.
@+.
jean-marc
0
Rejoignez-nous