I wonder if anyone can help me. I have a bunch of text files that contain a few thousand lines, and I just want to extract one element of each file.
A snippet of the contents of the files is like so:
<LastMassUpdateChange xsi:nil="true" />
<Notes />
<PropertyType1>House</PropertyType1>
<PropertyType2>SemiDetached</PropertyType2>
<PositionOfFlat xsi:nil="true" />
<FlatWhichFloor>0</FlatWhichFloor>
<FlatFloorsAbove>0</FlatFloorsAbove>
Where I just want to extract the text between <PropertyType2>
& </PropertyType2>
So in this case SemiDetached
and place this result next to the file url column.
The urls of the files will all be in a column within excel, so I need a loop vba to check each text file within that column, and put the result in the next column.
I had the following code to extract the data within a certain line, but I didn't realise the files were not all formatted with the same amount of lines so it hasn't worked out.
Any help greatly appreciated, thanks.
Sub extractpropertytype()
Dim d As Integer
' For d = 1 To Sheet2.Range("G" & Rows.Count).End(xlUp).Row
For d = 2 To Range("AE1").Value + 1
'Workbooks("Book1").Activate
Open Range("AA" & d).Value For Input Access Read As #1
For i = 1 To 80
Line Input #1, X
'Range("a1").Offset(i - 1, 0).Value = x
Next i
Line Input #1, X
Range("AB" & d) = X
Close #1
Next d
End Sub