toto.worksheets("titi").range("A" & rows.count).end(xlup).row + 1
ChDir "C:\Users\myname\Documents\1. Projects\wilko\Map_Packages\Test" Mappack = Dir("C:\Users\myname\Documents\1. Projects\wilko\Map_Packages\Test\*.txt") While Len(Mappack) > 0 Workbooks.Open Mappack AvantDerniereLigne = ActiveSheet.UsedRange.Rows.Count - 1 Range("A1:A3").Copy Workbooks("Book2.xlsm").Activate Range("A1:C1").Select Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=True, Transpose:=True Rows("1:1").Select Selection.Insert Shift:=xlDown Workbooks(Mappack).Close Mappack = Dir Wend
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionAvantDerniereLigne = ActiveSheet.UsedRange.Rows.Count - 1
chemin = "d:\titi\"
monfic = Dir(chemin & "\*.txt", vbDirectory Or vbReadOnly Or vbHidden Or vbSystem)
Do While monfic <> ""
If Range("A1").Value = "" Then
derlig = 1
Else
derlig = Range("A" & Rows.Count).End(xlUp).Row + 1
End If
Open chemin & monfic For Input As #1
For i = 0 To 2 ' ===>> on ne prend que trois lignes
If EOF(1) Then Exit For ' ==>> pour le cas où tu aurais moins de tes 3 lignes !
Line Input #1, toto
ActiveSheet.Range("A" & derlig).Offset(0, i).Value = toto
Next
Close #1
monfic = Dir
Loop
chemin = "d:\titi\"
monfic = Dir(chemin & "\*.txt", vbDirectory Or vbReadOnly Or vbHidden Or vbSystem)
Do While monfic <> ""
If Range("A1").Value = "" Then
derlig = 1
Else
derlig = Range("A" & Rows.Count).End(xlUp).Row + 1
End If
Open chemin & monfic For Input As #1
ActiveSheet.Range("A" & derlig & ":" & "C" & derlig) = Split(Input(LOF(1), #1), vbCrLf)
Close #1
monfic = Dir
Loop