donpopo
XLDnaute Occasionnel
Bonjour le forum,
Je cherche à remplir un textbox d'un formulaire avec la dernière cellule remplie d'une ligne précise. J'arrive à déterminer la ligne désirée, pas de problème.
Le seul problème est de déterminer la dernière cellule non vide et placer la valeur dans mon textbox
Voici la procédure concernée (les lignes en commentaires et en retrait représentent mon problème):
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
' Alimentation du formulaire UserForm2
Dim i As Long, j As Long, xlgn As Long, xdlgn As Long, xcol As Long, xmttl As Double, DerCol As Long
xdlgn = ActiveSheet.Range("C" & Rows.Count).End(xlUp).Row
If Not Application.Intersect(Target, Range("B5:B" & xdlgn)) Is Nothing Then
xlgn = Target.Row
xcol = ActiveSheet.Cells(xlgn, Columns.Count).End(xlToLeft).Column
If ActiveSheet.Cells(xlgn, 6) < "01/01/1900" Then
MsgBox "Aucun Compte-titres ne figure sur cette ligne.", vbInformation, "COMPTES-TITRES"
Exit Sub
End If
UserForm2.TextBox1.Value = Cells(xlgn, 3).Value
UserForm2.TextBox2.Value = Cells(xlgn, 8).Value
UserForm2.TextBox3.Value = Cells(xlgn, 6).Value
UserForm2.TextBox4.Value = Cells(xlgn, 9).Value
'DerCol = .Range(xlgn,
'UserForm2.TextBox5.Value = .Range(xlgn & DerCol)
UserForm2.TextBox7.Value = Cells(xlgn, 5).Value
UserForm2.TextBox8.Value = Cells(xlgn, 4).Value
UserForm2.TextBox10.Value = Cells(2, 4).Value
Range("A4").Activate
UserForm2.Show
End If
End Sub
Si quelqu'un peut m'aider,
Merci,
Donpopo
Je cherche à remplir un textbox d'un formulaire avec la dernière cellule remplie d'une ligne précise. J'arrive à déterminer la ligne désirée, pas de problème.
Le seul problème est de déterminer la dernière cellule non vide et placer la valeur dans mon textbox
Voici la procédure concernée (les lignes en commentaires et en retrait représentent mon problème):
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
' Alimentation du formulaire UserForm2
Dim i As Long, j As Long, xlgn As Long, xdlgn As Long, xcol As Long, xmttl As Double, DerCol As Long
xdlgn = ActiveSheet.Range("C" & Rows.Count).End(xlUp).Row
If Not Application.Intersect(Target, Range("B5:B" & xdlgn)) Is Nothing Then
xlgn = Target.Row
xcol = ActiveSheet.Cells(xlgn, Columns.Count).End(xlToLeft).Column
If ActiveSheet.Cells(xlgn, 6) < "01/01/1900" Then
MsgBox "Aucun Compte-titres ne figure sur cette ligne.", vbInformation, "COMPTES-TITRES"
Exit Sub
End If
UserForm2.TextBox1.Value = Cells(xlgn, 3).Value
UserForm2.TextBox2.Value = Cells(xlgn, 8).Value
UserForm2.TextBox3.Value = Cells(xlgn, 6).Value
UserForm2.TextBox4.Value = Cells(xlgn, 9).Value
'DerCol = .Range(xlgn,
'UserForm2.TextBox5.Value = .Range(xlgn & DerCol)
UserForm2.TextBox7.Value = Cells(xlgn, 5).Value
UserForm2.TextBox8.Value = Cells(xlgn, 4).Value
UserForm2.TextBox10.Value = Cells(2, 4).Value
Range("A4").Activate
UserForm2.Show
End If
End Sub
Si quelqu'un peut m'aider,
Merci,
Donpopo