Need help with a loop copying data from a worksheet to a text file

This is what I have tried

Do While Cells(j, 1) = Cells(j + 1, 1)

Print #iFile, "0" & Left(Range("A" & j).Value, 2) & " " & Range("D" & j).Value
Print #iFile, "1" & Range("B" & j).Value & LeftPadZeros(Range("C" & j).Value) _
& LeftPadZeros2(Range("E" & j).Value)
j = j + 1
cnt = cnt + 1

'Loop Until Cells(j, 1).Value <> Cells(j + 1, 1).Value
If Cells(j, 1).Value <> Cells(j + 1, 1).Value Then
Print #iFile, "9" & Left(Range("A" & j).Value, 2) _
& " " & LeftPadZeros3(cnt)
End If
Loop Until Cells(j, 1).Value <> Cells(j + 1, 1).Value

'End If
cnt = 0
Next j

I need all the rows that have the same data in Column A to eb grpd and only post that last if statemtn's data when the value in A changes, then do it again for the next value etc

Nick's picture

easiest is to write some code

easiest is to write some code to copy the data you need to a new sheet, then use this:

http://excelexperts.com/export-and-import-tab-delimited-text-file