Outputting Excel rows to a series of text files

后端 未结 3 1104
小蘑菇
小蘑菇 2020-11-27 20:02

Inside Excel, I have a list of article names in column A, and a disclaimer inside column B. Now for each article in column A, I would like to create a text file, were A is t

3条回答
  •  野趣味
    野趣味 (楼主)
    2020-11-27 20:41

    Another approach using variant arrays for speed, and an alternative to the FileSystemObject given only file creation is needed.

        Sub DataDump()
    
        Dim X
        Dim lngRow As Long
        Dim StrFolder As String
    
        StrFolder = "C:\temp"
        X = Range([a1], Cells(Rows.Count, 2).End(xlUp))
        For lngRow = 1 To UBound(X)
        Open StrFolder & "\" & X(lngRow, 1) & ".txt" For Output As #1
        Write #1, X(lngRow, 2)
        Close #1
        Next
        End Sub
    

提交回复
热议问题