Try
Sub test()
Dim myDir As String, fn As String, txt As String
Const myReplace As String = "0.0666 2222 2 0 "
myDir = ThisWorkbook.Path & "\" '<-- folder path
fn = Dir(myDir & "*.txt")
Do While fn <> ""
txt = CreateObject("Scripting.FileSystemObject") _
.OpenTextFile(myDir & fn).ReadAll
With CreateObject("VBScript.RegExp")
.Global = True
.MultiLine = True
.Pattern = "^(simulation results )([\d\. ]+)"
If .test(txt) Then
txt = .Replace(txt, "$1" & myReplace)
End If
End With
Open Replace(fn, ".txt", "_Updated.txt") For Output As #1
Print #1, txt
Close #1
fn = Dir
Loop
End Sub
Bookmarks