J'ai fais le calcul et j'arriverais à environ 618000. Si il n'y a juste qu'à augmenter cette valeur c'est dans mes cordes
j'ai trouvé comment le rendre variable, je vais modifier la macro
Option Explicit
Sub lancer()
Dim wb As Workbook, ws As Worksheet, donnees As Variant
Sheets("Bdd").Select
Set wb = ThisWorkbook
Set ws = ActiveSheet
Sheets("Bdd").Select
Range("A" & Rows.Count).End(xlUp).Offset(1, 0).Select
If Not ws.ListObjects(1).DataBodyRange Is Nothing Then
If MsgBox("Voulez-vous supprimer toutes les données ?", vbYesNo, "Demande de confirmation") = vbYes Then ws.ListObjects(1).DataBodyRange.Delete
End If
If ws.ListObjects(1).DataBodyRange Is Nothing Then Range("A5").Select
' choix du fichier source (texte)
donnees = Application.GetOpenFilename("Text Files (*.txt), *.txt")
If donnees = False Then Exit Sub
' importation des données
Extraction donnees, vbTab
' actualisation des TCD
Sheets("TCD 0h-0h").PivotTables(1).PivotCache.Refresh
Sheets("Récapitulatif").Select
End Sub
Sub Extraction(Fichier As Variant, Separateur As Variant)
Dim Tableau() As String
' en-têtes, pour t2 on trouvera en t2(3,i) la correspondance des colonnes utiles
Dim t1, t2(1 To 3, 1 To 35) ' 35 colonnes maxi fichier texte
Dim Resultat, nCol%
Dim ContenuLigne As String
Dim i As Integer, ii As Integer ' colonnes
Dim j As Double ' lignes
t1 = Sheets("Bdd").Range("A1:AD2")
Open Fichier For Input As #1
j = 1
Do While Not EOF(1)
Line Input #1, ContenuLigne
Tableau = Split(ContenuLigne, Separateur)
nCol = UBound(Tableau) + 1
Select Case True
Case j <= 2 ' en-têtes du fichier texte
For i = 0 To UBound(Tableau)
t2(j, i + 1) = Tableau(i)
Next i
If j = 1 Then ReDim Resultat(1 To nCol, 1 To 1)
If j = 2 Then ' recherche de correspondance
For i = 1 To 35
t2(3, i) = ""
For ii = 1 To UBound(t1, 2)
If t1(1, ii) & " " & t1(2, ii) = t2(1, i) & " " & t2(2, i) Then
t2(3, i) = ii ' colonne i texte correspond à colonne ii xlsm
End If
Next
Next
End If
Case j > 2 ' données
ReDim Preserve Resultat(1 To nCol, 1 To j - 2)
For i = 0 To UBound(Tableau)
If t2(3, i + 1) <> "" Then ' il existe une correspondance
If i = 0 Then 'date
Resultat(t2(3, i + 1), j - 2) = CDbl(DateSerial("20" & Mid(CStr(Tableau(i)), 7, 2), Mid(CStr(Tableau(i)), 4, 2), Mid(CStr(Tableau(i)), 1, 2)))
Else
Resultat(t2(3, i + 1), j - 2) = Tableau(i)
End If
End If
Next i
End Select
j = j + 1
Loop
Close #1
Resultat = Application.Transpose(Resultat)
Selection.Resize(UBound(Resultat), UBound(Resultat, 2)) = Resultat
End Sub
Sub raz()
Sheets("Bdd").Select
If Not ActiveSheet.ListObjects(1).DataBodyRange Is Nothing Then ActiveSheet.ListObjects(1).DataBodyRange.Delete
Sheets("TCD 0h-0h").PivotTables(1).PivotCache.Refresh
End Sub