Option Explicit
'-------------------------------------------
Sub MakeTextFiles()
'
' Macro to export first 4 columns 5 rows at _
a time to text files
'-------------------------------------------
Dim X As Long, Z As Long, FF As Long, TextOut As String
Const OutputPath As String = "c:\temp\" '<==Note the trailing backslash
Const BaseFileName As String = "Rows_" ' adjust base file name as you wish
Const StartColumn As Long = 1 'Assumed Column A
Dim StartRow As Long
StartRow = 1 'Assumed Row 1
Do While Cells(StartRow, StartColumn).Value <> vbNullString ' while not empty
TextOut = ""
For Z = StartRow To StartRow + 4 ' for 5 rows at a time
For X = StartColumn To StartColumn + 3 ' for 4 columns
' add the text of each cell separated by a space
TextOut = TextOut & Cells(Z, X).Value & " "
Next
TextOut = TextOut & vbCrLf ' add new line
Next
' Write this text string to a text file
FF = FreeFile
Open OutputPath & BaseFileName & StartRow & "-" & (Z - 1) & ".txt" For Output As #FF
Print #FF, TextOut
Close #FF
' increment start row
StartRow = Z
Loop
End Sub
this code is adjusted from code supplied by Rick Rothstein in thread
mrexcel.com/forum/excel-questions/646985-visual-basic-applications-export-range-text-files.html