Hi,
I have a notepad and I want to find a text into notepad.
Once I find the text in notepad then I want to replace entire line with new text.
This I want to do using Excel VBA.
I have written a code that searches in a file but replaces only the text which it finds but not the entire line.
Below is my code
I have a notepad and I want to find a text into notepad.
Once I find the text in notepad then I want to replace entire line with new text.
This I want to do using Excel VBA.
I have written a code that searches in a file but replaces only the text which it finds but not the entire line.
Below is my code
Code:
Open folderPath & "\XXXX_VARIABLE.txt" For Input As iFile2
text = Input$(LOF(1), iFile2)
arr = Split(text, vbNewLine)
Close iFile2
iFile2 = FreeFile
Open folderPath & "\XXXX_VARIABLE.txt" For Output As iFile2
For Each item In arr
line = Replace(CStr(item), SrchString, ReplString, 1)
Print #iFile2, line
Next
Close iFile2
Comment