Remplir listview2
bonjour
j'ai besoin de remplir listview2 en USFFORM multipage "base des livres" mais je n'arrive pas
merci de votre aide
bonjour
j'essaie mais c tres complique
Option Explicit
Private Sub CommandButton1_Click()
Unload Me
'UserForm2.Show
End Sub
Private Sub CommandButton2_Click()
Unload Me
End Sub
Private Sub MultiPage1_Change()
End Sub
Private Sub TextBox1_Change()
Call LVW_Fill(Trim$(TextBox1.Text), ComboBox1.ListIndex)
End Sub
Private Sub TextBox2_Change()
Call LVW_Fill(Trim$(TextBox2.Text), ComboBox2.ListIndex)
End Sub
Private Sub UserForm_Activate()
Me.Caption = "Bibliotheque"
Set ListView1.Icons = ImageList1
Set ListView1.SmallIcons = ImageList1
Set ListView2.Icons = ImageList2
Set ListView2.SmallIcons = ImageList2
Call CBO_Fill
Call LVW_Fill("", 0)
End Sub
Private Sub CBO_Fill()
'Variables locales
Dim iCnt As Integer
Dim oRng As Excel.Range
'Remplit la Combo
With ComboBox1
Set oRng = Sheets("Recherche").Cells(1, 1)
For iCnt = 0 To 13 '-- 14 colonnes
ComboBox1.AddItem oRng.Offset(0, iCnt)
Next iCnt
ComboBox1.ListIndex = 0
End With
With ComboBox2
Set oRng = Sheets("base des livres").Cells(1, 1)
For iCnt = 0 To 12 '-- 13 colonnes
ComboBox1.AddItem oRng.Offset(0, iCnt)
Next iCnt
ComboBox1.ListIndex = 0
End With
End Sub
Private Sub LVW_Fill(ByVal sFilter As String, ByVal iCol As Integer)
'Variables locales
Dim iCnt As Integer
Dim iRnd As Integer
Dim oRng As Excel.Range
Dim oItem As ListItem
'Initialisation de la ListView
With ListView1
ListView1.ColumnHeaders.Clear
ListView1.FullRowSelect = True
ListView1.ListItems.Clear
ListView1.View = lvwReport
'Remplissage de la ListView
Set oRng = Sheets("Recherche").Cells(1, 1)
Do Until oRng.Offset(0, 0).Value = ""
'-- En-têtes
If oRng.Row = 1 Then
For iCnt = 0 To 13 '-- 14 colonnes
ListView1.ColumnHeaders.Add , , oRng.Offset(0, iCnt)
Next iCnt
'-- Données
Else
iRnd = Int((4 * Rnd) + 1)
If LCase$(Left$(oRng.Offset(0, iCol), Len(sFilter))) = LCase$(sFilter) Then
Set oItem = ListView1.ListItems.Add(, , oRng.Offset(0, 0), "Key" & iRnd, "Key" & iRnd)
For iCnt = 1 To 14 '-- 14 colonnes
oItem.ListSubItems.Add , , oRng.Offset(0, iCnt)
Next iCnt
End If
End If
Set oRng = oRng.Offset(1, 0)
Loop
End With
With ListView2
ListView2.ColumnHeaders.Clear
ListView2.FullRowSelect = True
ListView2.ListItems.Clear
ListView2.View = lvwReport
'Remplissage de la ListView
Set oRng = Sheets("base des livres").Cells(1, 1)
Do Until oRng.Offset(0, 0).Value = ""
'-- En-têtes
If oRng.Row = 1 Then
For iCnt = 0 To 12 '-- 13 colonnes
ListView2.ColumnHeaders.Add , , oRng.Offset(0, iCnt)
Next iCnt
'-- Données
Else
iRnd = Int((4 * Rnd) + 1)
If LCase$(Left$(oRng.Offset(0, iCol), Len(sFilter))) = LCase$(sFilter) Then
Set oItem = ListView2.ListItems.Add(, , oRng.Offset(0, 0), "Key" & iRnd, "Key" & iRnd)
For iCnt = 1 To 13 '-- 13 colonnes
oItem.ListSubItems.Add , , oRng.Offset(0, iCnt)
Next iCnt
End If
End If
Set oRng = oRng.Offset(1, 0)
Loop
End With
End Subamicalement
BONJOUR
je fais plusieurs tentatives mais sans résultat
comment débuter en A1 au lieu de A2
Private Sub CommandButton2_Click()
Dim i As Integer
Dim maLigne As Long
Dim DernCol As Integer
maLigne = Range("A" & Rows.Count).End(xlUp).Row + 1
DernCol = Range("A1").End(xlToRight).Column
'ajout les textbox a la feuille base des livres
With Worksheets("base des livres")
For i = 1 To DernCol
Cells(maLigne, i) = Me.Controls("TextBox" & i - 1)
Next i
End With
End Submerci de votre aide
Bonjour Richi2casa
Pour commencer ta liste en A1, tu dois supprimer la ligne des titres qui se trouvent en A1
Le code remonte vers la 1ère ligne non vide et décale de 1 vers le bas
Donc rencontre la ligne des titres et descend de 1 ligne soit A2
Amicalement
Pierrot
BONJOUR
Au lieu de je commence à A1 je commence à B1
ou est mon erreur?
Private Sub CommandButton2_Click()
Dim i As Integer
Dim maLigne As Long
Dim DernCol As Integer
maLigne = Range("A" & Rows.Count).End(xlUp).Row + 1
DernCol = Range("A1").End(xlToRight).Column
'ajout les textbox a la feuille base des livres
With Worksheets("base des livres")
For i = 1 To DernCol
Cells(maLigne, i) = Me.Controls("TextBox" & i )
Next i
End With
End Submerci de votre aide
bonjour
je trouve une solution
mais reste recherche par filtre qlqu'un peux m'aider ?
Private Sub CommandButton2_Click()
Dim i As Integer
Dim maLigne As Long
'Dim DernCol As Integer
maLigne = Range("A" & Rows.Count).End(xlUp).Row + 1
'ajout les textbox a la feuille base des livres
With Worksheets("base des livres")
For i = 1 To 14
Cells(maLigne, i) = Me.Controls("TextBox" & i + 1)
Me.Controls("TextBox" & i + 1) = ""
Next i
End With
End SubBonjour
Je suis presque terminé l'application
-mais je bloque au niveau du calcul ( stck,sortie entre .........)
merci pour tous
je change l'adresse (titre) simplifier le code