[英]How do I get the text from a .txt file and write it in a new sheet in the same excel file
I want a whole text file to enter into a new sheet in excel.我希望将整个文本文件输入到 excel 中的新工作表中。 Right now I am only getting all values in to one cell, I want it to look like in the text file.
现在我只将所有值放入一个单元格中,我希望它看起来像在文本文件中。 Like every row get one row in excel.
就像每一行在 excel 中得到一行。
I have tried this tutorial but this doesn't get it.我已经尝试过本教程,但没有得到它。
https://www.excel-easy.com/vba/examples/read-data-from-text-file.html https://www.excel-easy.com/vba/examples/read-data-from-text-file.html
I solved it for you who wants to know how check below我为想知道如何查看以下内容的您解决了
Sub GetText()
Dim SheetName As String
Dim TMPWorkBook As Workbook
Dim FilePath As String
Dim TxtFilePath As String
Dim TxtFileName As String
Set WB = ThisWorkbook
SheetName = "Test_Result"
TxtFileName = "C:\getitdone.txt"
Workbooks.OpenText Filename:= _
TxtFileName _
, Origin:=437, StartRow:=1, DataType:=xlDelimited, TextQualifier:= _
xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=False, Semicolon:=False, _
Comma:=False, Space:=False, Other:=True, OtherChar:="|", FieldInfo:=Array(Array(1, 1), _
Array(2, 1)), DecimalSeparator:=".", ThousandsSeparator:=",", _
TrailingMinusNumbers:=True
Set TMPWorkBook = ActiveWorkbook
Cells.Select
Selection.Copy
Workbooks("Getitdone.xlsm").Activate
Sheets.Add.Name = "Data"
Range("A1").PasteSpecial xlPasteValues
End Sub
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.