macro de recherche listbox transformer pour une listeview

cpeens

XLDnaute Occasionnel
Bonjour à tous j'utilise une macro qui mer permet de faire une recherche sur une periode de date j'ulilise pour cela une listbox et cette macro

Code:
Option Explicit
Option Base 1

Dim TabGeneral As Variant
Dim TabRecup() As Variant
Dim rng As Range

Dim DerLigne As Long
Dim Lgn As Long

Dim DerCol As Integer

Dim X As Long

Dim DateDebut As Long
Dim DateFin As Long

Sub Search()
Dim Recherche As Object
X = 0
With USF1

If .R1 = "" Or .R2 = "" Then Exit Sub

If Not IsDate(.R1) Or Not IsDate(.R2) Then Exit Sub
.ListBox1.clear
DateDebut = Format(.R1, "00000"): DateFin = Format(.R2, "00000")
End With
Application.ScreenUpdating = False

With Worksheets("BDD")
DerLigne = .Cells(.Rows.Count, 1).End(xlUp).Row
DerCol = .Cells(1, .Columns.Count).End(xlToLeft).Column
Set rng = .Range(.Cells(2, 1), .Cells(DerLigne, DerCol))
End With
With rng
.Sort Key1:=Range("A2"), Order1:=xlDescending, Header:=xlGuess
TabGeneral = .Value
End With
For Lgn = 1 To UBound(TabGeneral, 1)
If Format(TabGeneral(Lgn, 3), "00000") >= DateDebut And Format(TabGeneral(Lgn, 3), "00000") <= DateFin And TabGeneral(Lgn, 6) = USF1.Deb_Vac.Caption Then
X = X + 1
ReDim Preserve TabRecup(7, X)
TabRecup(1, X) = TabGeneral(Lgn, 1)
TabRecup(2, X) = TabGeneral(Lgn, 2)
TabRecup(3, X) = TabGeneral(Lgn, 3)
TabRecup(4, X) = TabGeneral(Lgn, 4)
TabRecup(5, X) = TabGeneral(Lgn, 5)
TabRecup(6, X) = TabGeneral(Lgn, 6)


End If

Next Lgn

With USF1.ListBox1
If X > 1 Then
.List = Application.Transpose(TabRecup)
ElseIf X = 1 Then
.Column = Application.Transpose(TabRecup)
End If
End With
End Sub

le probleme c'est que j'utilise aussi une fonction par mot clef et la j'utilise une listview
et cette macro
Code:
Dim i&, fin&
  
    If R3 = "" Then ListView1.ListItems.clear: Exit Sub
    fin = Feuil3.Range("A65536").End(xlUp).Row
    mm = Feuil3.Range("A2:AH" & fin)
    For i = 1 To UBound(mm)
        For a = 1 To UBound(mm, 2)
            If mm(i, a) Like "*" & R3 & "*" Then mm(i, 34) = "oui"
        Next a
    Next i
    y = 1
    For i = 1 To UBound(mm)
        If mm(i, 34) = "oui" Then y = y + 1
    Next
    If y < 2 Then ListView1.ListItems.clear: GoTo 1
    ReDim bb(y - 1, 33)
    y = 1
    For i = 1 To UBound(mm)
        If mm(i, 34) = "oui" Then
            For a = 1 To 33
                bb(y, a) = mm(i, a)
            Next a
            y = y + 1
        End If
    Next i
    With ListView1
        .ListItems.clear
        .View = lvwReport
        .FullRowSelect = True
        .Gridlines = True
        For i = 1 To UBound(bb)
            .ListItems.Add , , bb(i, 1)
            For a = 2 To UBound(bb, 2)
                .ListItems(.ListItems.Count).ListSubItems.Add , , bb(i, a)
            Next a
        Next i
1   End With
End Sub
ma question est la suivante comment faire pour avoir les deux fonction sur soit dans listbox soit soit une listview.

merci d'avance de votre aide
 

Discussions similaires

Réponses
6
Affichages
343
Réponses
11
Affichages
347

Statistiques des forums

Discussions
312 493
Messages
2 088 949
Membres
103 989
dernier inscrit
jralonso