Right click the sheet's tab, View Code, and paste.
Change the path in txtPath to suit. To update current entries, cut A2 and down and paste back. Then, any change in A will update B.
Private Sub Worksheet_Change(ByVal Target As Range)
Dim c As Range, r As Range, txtPath As String
Dim hCell As Range, fn As String, fnTXT As String
Dim glb_origCalculationMode As Integer, fso As Object
On Error GoTo EndSub
glb_origCalculationMode = Application.Calculation
With Application
.Calculation = xlCalculationManual
.ScreenUpdating = False
.EnableEvents = False
.DisplayAlerts = False
.Cursor = xlWait
.StatusBar = "Adding txt file contents..."
.EnableCancelKey = xlErrorHandler
End With
Set r = Intersect(Target, Columns("A"))
If r Is Nothing Then Exit Sub
Set fso = CreateObject("Scripting.FileSystemObject")
txtPath = ThisWorkbook.Path & "\" 'Path to .txt files with trailing \.
'If Not fso.FileExists(txtPath) Then Exit Sub
For Each c In r
Set hCell = c.Offset(, 1)
fn = c.Value
fnTXT = txtPath & fn & ".txt"
Select Case True
Case fn = ""
hCell.Value = ""
Case fso.FileExists(fnTXT)
With hCell
'https://msdn.microsoft.com/en-us/library/aa265341(v=vs.60).aspx
'http://www.exceltrick.com/formulas_macros/filesystemobject-in-vba/
.Value = fso.GetFile(fnTXT).OpenAsTextStream(1, -2).ReadAll
'.Value = Replace(fso.GetFile(fnTXT).OpenAsTextStream(1, -2).ReadAll, vbCrLf, vbLf)
.WrapText = True
Columns(.Column).EntireColumn.AutoFit
Rows(.Row).EntireRow.AutoFit
End With
Range(c, hCell).VerticalAlignment = xlCenter
Case Else
End Select
Next c
EndSub:
With Application
.Calculation = glb_origCalculationMode
.ScreenUpdating = True
.EnableEvents = True
.DisplayAlerts = True
.CalculateBeforeSave = True
.Cursor = xlDefault
.StatusBar = False
.EnableCancelKey = xlInterrupt
End With
Set fso = Nothing
End Sub