|
他の方からレスがついているようなので、
そちらをお使いになったほうが良さそうですが、
一応載せときます。
Sub test()
Dim objText As Object
Dim FileName As String
Dim MyReplace As String
Dim i As Long
FileName = "C:\My Documents\Test.Txt"
Set objText = CreateObject("Scripting.FileSystemObject").OpenTextFile(FileName, 1)
i = 1
Do
Cells(i, 1).Value = objText.ReadLine
i = i + 1
Loop Until objText.AtEndOfStream
objText.Close
MyReplace = "hogehoge"
Range("A1", Range("A65536").End(xlUp)).Offset(0, 1).FormulaR1C1 = _
"=""" & MyReplace & """&MID(R[0]C[-1],9,LEN(R[0]C[-1])-8)"
Set objText = CreateObject("Scripting.FileSystemObject").OpenTextFile(FileName, 2)
For i = 1 To Range("B65536").End(xlUp).Row
objText.WriteLine (Cells(i, 2).Value)
Next
objText.Close
End Sub
|
|