frerofrero
New Member
- Joined
- Jun 2, 2022
- Messages
- 2
- Office Version
- 365
- Platform
- Windows
Dear all,
I am being new to VBA (learned about the existance of VBA 2 weeks ago), and I have a question about the extraction of data from a txt file.
I have a code that extracts the data of a txt file to my excel sheet, and I wanted to know about the existence of a formula that could only extract specific lines. Example = if i want to extract lines 7, 11 and 13 is there something that could do it ? I think it is important to precise that at the begining of every line that I want to extract, there is "62C" or "62D".
For now, my code is the following :
Sub MT940Date()
Dim theDate As Date e
Dim SOF As String
Dim EOF As String
Dim FileName As String
theDate = Date
DOF = Format(theDate, "yyyymmdd")
SOF = "TEXT; \\url of my file on my computer" 'Start Of File
EOF = ".rf0" 'End Of File
FileName = SOF & DOF & EOF
MsgBox FileName
With ActiveSheet.QueryTables.Add(Connection:=FileName, Destination:=Range("$A$1"))
.Name = "Sample"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 437
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = True
.TextFileSpaceDelimiter = True
.TextFileColumnDataTypes = Array(1, 1, 1, 1, 1, 1)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With
End Sub
Thanks to everyone in advance,
Kind Regards
I am being new to VBA (learned about the existance of VBA 2 weeks ago), and I have a question about the extraction of data from a txt file.
I have a code that extracts the data of a txt file to my excel sheet, and I wanted to know about the existence of a formula that could only extract specific lines. Example = if i want to extract lines 7, 11 and 13 is there something that could do it ? I think it is important to precise that at the begining of every line that I want to extract, there is "62C" or "62D".
For now, my code is the following :
Sub MT940Date()
Dim theDate As Date e
Dim SOF As String
Dim EOF As String
Dim FileName As String
theDate = Date
DOF = Format(theDate, "yyyymmdd")
SOF = "TEXT; \\url of my file on my computer" 'Start Of File
EOF = ".rf0" 'End Of File
FileName = SOF & DOF & EOF
MsgBox FileName
With ActiveSheet.QueryTables.Add(Connection:=FileName, Destination:=Range("$A$1"))
.Name = "Sample"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 437
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = True
.TextFileSpaceDelimiter = True
.TextFileColumnDataTypes = Array(1, 1, 1, 1, 1, 1)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With
End Sub
Thanks to everyone in advance,
Kind Regards