With the help of the below code I am not able to copy the text in text files in excel cell if the text in file starts with "="
How can I modify the code?
Code:Sub santa() Dim r As Range, txt As String, msg As String With Sheets("input") For Each r In .Range("a2", .Range("a" & Rows.Count).End(xlUp)) If r <> "" Then If Dir(r.Text) <> "" Then txt = CreateObject("Scripting.FileSystemObject").OpenTextFile(r.Text).ReadAll r(, 2) = txt r(, 3) = Join(Filter(Split(txt, vbNewLine), "VBA-2", True, 1), vbLf) Else msg = msg & vbLf & r.Text End If End If Next End With If Len(msg) Then MsgBox "File not fouond" & msg End Sub




Reply With Quote

Bookmarks