1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
Option Base 1
Dim Tablo(), Tablo2(), Xlignes As Integer, rep As String, Col As Byte, ws As Worksheet
Application.ScreenUpdating = False
If TextBox1 <> "" Then
Select Case TextBox1
Case "CP1"
Counter = 0
Set ws = Workbooks("HLSM DataBase.xlsm").Sheets("Fiche CP1")
If Not ws.ListObjects(1).DataBodyRange Is Nothing Then ws.ListObjects(1).DataBodyRange.Delete 'si le tableau est non vide alors on le vide
With Workbooks("HLSM DataBase.xlsm").Sheets("Base élèves")
For Xlignes = 7 To .Cells(Rows.Count, "F").End(xlUp).Row 'boucle sur les lignes
If .Cells(Xlignes, "F") Like TextBox1 Then 'recherche
Counter = Counter + 1 'incrémenter la solution de la recherche
ReDim Preserve Tablo(6, Counter) 'redimensionner le tableau
For Col = 2 To 6 'boucle sur les colonnes
Tablo(Col, Counter) = .Cells(Xlignes, Col) 'mettre la valeur de la recherche dans le tableau
Next
ReDim Preserve Tablo2(1, Counter)
Tablo2(1, Counter) = .Cells(Xlignes, "N") & " ans"
End If
Next
ws.Range(Cells(12, "B"), Cells(Counter, Col)) = Application.Transpose(Tablo) 'transposer le tableau sur la feuille
ws.Range(Cells(12, "H"), Cells(Counter, 8)) = Application.Transpose(Tablo2)
End With |
Partager