XL 2016 N° de ligne dans une textbox

filouplatchaud

XLDnaute Occasionnel
Bonjour a tous

quand je clic dans une cellule cela ouvre mon formulaire, la date qui correspond a la cellule aussi
et je voudrais que dans ma textbox5 celle en blanc le N° de la chambre apparaisse

c'est possible ?

merci de votre aide
 

Pièces jointes

  • Chambres-2017('_')essai.xlsm
    459.3 KB · Affichages: 30

Bebere

XLDnaute Barbatruc
bonjour
ligne 7 entrer chambre 2 en A
Code:
Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not Application.Intersect(Target, Range("c5:nc19")) Is Nothing Then
If ActiveCell.Value <> "" Then
'With ActiveCell
UserForm2.TextBox5 = Cells(Target.Row, "A").Value
UserForm2.Show
'End With
End If
End If

End Sub
 

job75

XLDnaute Barbatruc
Bonjour filouplatchaud, Bebere,

Code:
Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not Intersect(ActiveCell, [C5:NC19]) Is Nothing And ActiveCell <> "" Then UserForm2.Show
End Sub
Code:
Private Sub UserForm_Initialize()
Dim o As Object
TextBox1 = Format(Cells(3, ActiveCell.Column), "ddd dd mmmm")
For Each o In ActiveSheet.DrawingObjects
  If o.TopLeftCell.Row = ActiveCell.Row Then TextBox5 = o.Text: Exit For
Next
End Sub
Donnez une largeur suffisante à vos TextBox...

A+
 

Si...

XLDnaute Barbatruc
Bon_jour

Dans le fichier joint, avec des commentaires de cellule moins longs (Chambre N°x inutile), et avec le commentaire au survol du contrôle :

VB:
Private Sub UserForm_Initialize()
  TextBox1 = Format(ActiveCell.Value, "" & "ddd dd mmmm")
  TextBox5 =(ActiveCell.Row - 2) \ 2
  TextBox5.ControlTipText = ActiveCell.Comment.Text
End Sub
 

Pièces jointes

  • Réservation Chambres.xlsm
    432.2 KB · Affichages: 18
Dernière édition:

Discussions similaires

  • Question
Microsoft 365 #N/A
Réponses
6
Affichages
249

Statistiques des forums

Discussions
312 320
Messages
2 087 223
Membres
103 497
dernier inscrit
JP9231