Public Sub CasseTete()
Dim bytColRef As Byte, bytElement As Byte
Dim intRow As Integer, intNbRow As Integer
Dim strtTableau() As String
Dim strFichier As String
[color=green4]' Mes données commence toujours à la colonne 8 et ligne 2[/color]
[color=green4]' Mais le nombre de colonne et le nombre de ligne est variable[/color]
intNbRow = Cells(65536, 8).End(xlUp).Row
bytColRef = Cells(2, 255).End(xlToLeft).Column
ReDim strTableau(intNbRow - 2)
For intRow = 2 To intNbRow
With Range(Cells(intRow, 8), Cells(intRow, bytColRef))
[color=green4]' Ici j'aurais aimé remplacer la boucle appliquer:[/color]
[color=green4]' strTableau(intRow - 2) = Join(.value2(1))[/color]
strTableau(intRow - 2) = .Value2(1, 1)
For bytElement = 2 To .Count - 1
strTableau(intRow - 2) = strTableau(intRow - 2) & Chr(32) & .Value2(1, bytElement)
Next bytElement
End With
Next intRow
strFichier = Join(strTableau(), vbCrLf)
Kill 'c:\Test.txt'
Open 'C:\Test.txt' For Binary As #1
Put #1, , strFichier [color=green4]'strTableau()[/color]
Close #1
End Sub