Sub CopyTextFile()
Worksheets.Add().Name = "PullSheet" 'Make the sheet for the data from txt file to go into
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;C:\Users\Tyger\Desktop\test2.txt", Destination:=Range("$A$1"))
'Change Connection to your file location and Desitnation to where you want to paste
.Name = "test2" 'Name of connection
.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 = True
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = True
.TextFileCommaDelimiter = False
.TextFileSpaceDelimiter = True
.TextFileColumnDataTypes = Array(1, 1, 1, 1, 1)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With
'Pull Sheet was Made
'Now Begins Looping through data to move it to results sheet
lastRowCOlA = Sheets("PullSheet").Range("A65536").End(xlUp).Row 'Finds he number of the last cell in Column A in Pullsheet
For Each Cell In Sheets("PullSheet").Range("A1", Range("A1").Offset(lastRowCOlA, 0)) 'Sets to look in each cell in range of data in column A
'Start Point 1
lastRowCOlA = Sheets("Results").Range("A65536").End(xlUp).Row ' Gets the next open cell in Colmn A of results page
If Cell.Value = "insert_job:" Or Cell.Value = "update_job:" Then 'Checks if cell equals criteria if it doesn't skips to next cell
JobName = Cell.Offset(0, 1).Value ' Sets JobName as the value of the cell one to the right
If JobName = "" Then ' If the cell is blank
JobName = "NA" ' change it from blank to NA IT MUST HAVE A VALUE NOT A BLANK
End If ' Stops First IF
End If ' Stops Second IF
Sheets("Results").Range("A" & lastRowCOlA + 1).Value = JobName ' Puts JobName in next open cell in results
' Ends looking in Job Names From Text File To Results Page
' End Point 1
' Starts checking if cell is equal to description
'Start Point 2
LastRowColB = Sheets("Results").Range("B65536").End(xlUp).Row ' Find Next empty cell in column b of results
If Cell.Value = "description:" Then 'Checks if cell equals criteria
Note = Cell.Offset(0, 1).Value 'Grabs value of cell one to the right
If Cell.Value = "" Then ' Checks if cell is blank IT CANNOT BE SO IF IT IS
Cell.Value = "Na" ' Change Cell Value to NA to be pasted into results sheet and not mess up code to find next open cell
End If
End IF
Sheets("Results").Range("B" & LastRowColB + 1).Value = Note 'Inputs value into results page
' Ends looking for Descrtiption
'End Point 2
'Need to add more Start and End Points for each Tag in your Txt File
Next ' Loops Back to check Next Cell in Column A
' Since Jobtype is under a different column than all the other data need new for ecah statement
LastRowCOlC = Sheets("PullSheet").Range("C65536").End(xlUp).Row ' Finds last cell in column c of pull sheet
For Each Cell In Sheets("PullSheet").Range("C1", Range("C1").Offset(LastRowCOlC, 0)) 'Sets loop for all items in Colmn C
lastRowCOlD = Sheets("Results").Range("D65536").End(xlUp).Row ' Sets next Blank row in Results sheet
If Cell.Value = "job_type" Then ' Checks if cell is equal to criteria
Note = Cell.Offset(0, 1).Value ' if does match copies cell one over to the right
If Cell.Value = "" Then ' Checks if blank
Cell.Value = "Na" ' Change blank to NA caues cannot have a blank breaks code
End If ' stops first if
End IF ' stops second if
Sheets("Results").Range("D" & lastRowCOlD + 1).Value = Note ' Sets next blank cell in results to found value
Next ' Loops to next cell in Range of Column C we set
Application.DisplayAlerts = False 'Turns off pop up windows so it wont ask you if are sure you want to delete page
Sheets("PullSheet").Delete ' Deletes page ...not needed but I like temp pages and you wanted connection gone
Application.DisplayAlerts = True ' Turns back on
' Below Will remove all Na and replace with blank
For Each cell In ActiveSheet
If cell.Value = "Na" Then Cell.Clear
Nex
End Sub