As an example, I used the answer from the link I posted in comments.
I put a simple loop inside that loops the range, creating a row in the text file for each value.
Then I call with from another sub (not something you have to do) from within a loop that loop through all the rows, and for each row, passes the range of all the used column in said row. This specific code requires you to add a reference to Microsoft Scripting Runtime
.
Option Explicit
Sub SaveNfo()
Dim ws As Worksheet, rng As Range, LastColumn As Range, rngRow As Variant
Set ws = Worksheets(1)
Set rng = ws.Range("A3:A" & ws.Cells(ws.Rows.Count, "A").End(xlUp).Row) 'start on row 3, include all rows with a filepath
For Each rngRow In rng
If Not rngRow = "" Then
SaveTextToFile rngRow & rngRow.Offset(, 1), _
ws.Range(rngRow.Offset(, 2), Cells(rngRow.Row, ws.Cells(rngRow.Row, ws.Columns.Count).End(xlToLeft).Column))
End If
Next
End Sub
Private Sub SaveTextToFile(filePath As String, rng As Range)
Dim cell As Variant
Dim fso As FileSystemObject
Set fso = New FileSystemObject
Dim fileStream As TextStream
' Here the actual file is created and opened for write access
Set fileStream = fso.CreateTextFile(filePath)
' Write something to the file
For Each cell In rng
fileStream.WriteLine cell
Next
' Close it, so it is not locked anymore
fileStream.Close
End Sub
If the file name column doesn't include .nfo you can add that in the code manually:
SaveTextToFile rngRow & rngRow.Offset(, 1), _
Becomes
SaveTextToFile rngRow & rngRow.Offset(, 1) & ".nfo", _
rngRow
points to the "A" column, for the path.
rngRow.Offset(, 1)
is then the "B" column, for the name.
rngRow.Offset(, 2)
is then ofc "C", where we start looking for data to put in the file.
Or, if you want the really short version:
Sub SaveNfo()
Dim rngRow As Variant, cell As Variant, fso As Object, fileStream As Object
For Each rngRow In Range("A3:A" & Cells(Rows.Count, "A").End(xlUp).Row)
If Not rngRow = "" Then
Set fso = CreateObject("Scripting.FileSystemObject")
Set fileStream = fso.CreateTextFile(rngRow & rngRow.Offset(, 1))
For Each cell In Range(rngRow.Offset(, 2), Cells(rngRow.Row, Cells(rngRow.Row, Columns.Count).End(xlToLeft).Column))
fileStream.WriteLine cell
Next
fileStream.Close
End If
Next
End Sub