Microsoft 365 msgBox : afficher contenu de la cellule cliquée

Usine à gaz

XLDnaute Barbatruc
Supporter XLD
Bonjour à toutes et à tous,
Je vous souhaite une belle journée pleine de soleil :)

Je me tourne à nouveau vers nos ténors pour un codage que je n'arrive pas à faire.

J'ai un code qui m'a été "concocté" sur notre forum et j'en remercie encore l'auteur car il fonctionne toujours super bien :
VB:
Private Sub Worksheet_SelectionChange(ByVal R As Range)
If Not Intersect(R, Range("f4")) Is Nothing And R.Count = 1 Then

If Not Intersect(R, Range("f4:f10")) Is Nothing And R.Count = 1 Then
Application.EnableEvents = False: Application.ScreenUpdating = False
MsgBox Range("f4")
[a1].Select
Application.EnableEvents = True: Application.ScreenUpdating = True
Exit Sub
End If
End If
End Sub

Si je clique sur ma cellule F4, j'ai bien le msgBox qui apparait avec le contenu de la cellule :
1622622316904.png

Pour m'en servir dans un autre fichier de travail, j'aimerais pouvoir afficher le msgBox pour chaque cellule cliquée, par exemple de "F4:F100"
Je n'arrive pas à le faire.
Pouvez-vous m'aider ?
Je joins un petit fichier test,
Avec mes remerciements,
lionel,
 

Pièces jointes

  • cellule_msgBAffiche.xlsm
    17 KB · Affichages: 16
Solution
Bonjour Lionel, Marcel32,

Une simple TextBox sur la feuille fait l'affaire, il me semble qu'on a déjà vu ensemble un truc comme ça :
VB:
Private Sub Worksheet_SelectionChange(ByVal R As Range)
With TextBox1
    .Visible = False
    If Intersect(ActiveCell, [F4:F27]) Is Nothing Or ActiveCell = "" Then Exit Sub
    .Top = ActiveCell.Top
    .Left = ActiveCell.Offset(, 1).Left + 5
    .Text = ActiveCell
    .SelStart = 0
    .Visible = True
End With
End Sub

Private Sub TextBox1_Change()
Application.ScreenUpdating = False
ActiveCell = TextBox1
ActiveCell.WrapText = False
End Sub
A+

Discussions similaires