An Example Using Write # and Input #
Sub TestWriteInput()
Dim lOutputFile As Long
Dim rg As range
Set rg = ThisWorkbook.Worksheets(1).range("a1")
lOutputFile = FreeFile
Open "C:\Write Example.txt" For Output As #lOutputFile
Do Until IsEmpty(rg)
Write #lOutputFile, rg.value, _
rg.Offset(0, 1).value, _
rg.Offset(0, 2).value, _
rg.Offset(0, 3).value, _
rg.Offset(0, 4).value, _
rg.Offset(0, 5).value, _
rg.Offset(0, 6).value, _
rg.Offset(0, 7).value
Set rg = rg.Offset(1, 0)
Loop
Set rg = Nothing
Close lOutputFile
Dim lInputFile As Long
Dim v1, v2, v3, v4
Dim v5, v6, v7, v8
Set rg = ThisWorkbook.Worksheets(2).range("a1")
rg.CurrentRegion.ClearContents
lInputFile = FreeFile
Open "C:\Write Example.txt" For Input As lInputFile
Do Until EOF(lInputFile)
Input #lInputFile, v1, v2, v3, v4, v5, v6, v7, v8
rg.value = v1
rg.Offset(0, 1).value = v2
rg.Offset(0, 2).value = v3
rg.Offset(0, 3).value = v4
rg.Offset(0, 4).value = v5
rg.Offset(0, 5).value = v6
rg.Offset(0, 6).value = v7
rg.Offset(0, 7).value = v8
Set rg = rg.Offset(1, 0)
Loop
Set rg = Nothing
Close lInputFile
End Sub
Related examples in the same category