如何将单元格值replace为TextFile

我对VBA很新。 现在我想练习使用一个简单的问题。

我有一个包含ff值的excel文件:

Juan Miguel 28 John Smith 25 

我想用文本文件中的每个单元格replace这些值单元格。

假设我的文本文件是这样的:

 FirstName Person1: $A1 LastName Person1: $B1 Age Person1: $C1 FirstName Person2: $A2 LastName Person2: $B2 Age Person2: $C2 

有没有可能有这个,而不是使用下面的代码硬编码我的代码内的testing文件的内容?

 Print #TextFile, "Hello Everyone!" 

你可以使用这段代码来开始:

 Dim i As Long, lastRow As Long Set mySheet= ActiveSheet lastRow = mySheet.Cells(Rows.Count, "A").End(xlUp).Row For i = 1 To lastRow Print #TextFile, "FirstName Person" & CStr(i) & ": " & mySheet.Cells(i,1).Text Print #TextFile, "LastName Person" & CStr(i) & ": " & mySheet.Cells(i,2).Text Print #TextFile, "Age Person" & CStr(i) & ": " & mySheet.Cells(i,3).Text Print #TextFile, 'print a blank line Next i