[vbexcel]Comptage de ligne
Je voudrais de l'aide pour afficher les lignes sans écraser les anciennes.
Dans ce code je copie les lignes d'un fichier et je les colle dans MON fichier
et ceci je le fais pour 5 fichiers xls. Le probleme c'est que j'arrive pas à les coller sans écraser les dernières. Je n'arrive pas utiliser la fonction count qui ne se reinitialise pas.
Code:
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
|
Dim tab_nom_fichier, tab_nb_ligne, Path As String
Dim i, j, n, der_chrono, cumul_ligne As Integer
sonNom
Path = "D:\Documents and Settings\ldcg10126\Chrono\"
tab_nom_fichier = Array("CHRONO_1.xls", "CHRONO_2.xls", "CHRONO_3.xls", "CHRONO_4.xls", "CHRONO_5.xls")
Set zoneDONNEES = Workbooks(son_nom).Worksheets("Données").Range("A3").CurrentRegion
LastLineDONNEES = zoneDONNEES.Rows.Count
For i = 0 To 4
Workbooks.Open Path + tab_nom_fichier(i)
While Workbooks(tab_nom_fichier(i)).Worksheets("chrono").Cells(der_chrono + 4, 1).Value <> ""
der_chrono = der_chrono + 1
Wend
For j = 0 To der_chrono
For n = 1 To 13
Workbooks(son_nom).Worksheets("Données").Cells(j + LastLineDONNEES, n).Value = Workbooks(tab_nom_fichier(i)).Worksheets("chrono").Cells(j + 4, n).Value
Next n
Next j
Workbooks(tab_nom_fichier(i)).Close savechanges:=False
Next i |