Copying cell values to a external file in VBA
Hi, Matt-
Not sure if I'm seeing a time lag with Google's newsgroup interface or
if this message didn't post properly, so I'll post the code again. I
got your expected results with this code:
Sub Report_Body()
Dim Output As String
Range("a1").Select 'this assumes your data starts in cell A1
Open "C:\Documents and Settings\mcragg\My Documents\Excel Reports\CWPS
Folder\Record.txt" For Output As #1
Do While InStr(1, ActiveCell.Value, "2") 0 'run when the entry in col
A contains a 2
Output = ActiveCell.Value & "," & ActiveCell.Offset(0, 1).Value & ","
& ActiveCell.Offset(0, 2).Value & "," & ActiveCell.Offset(0, 3).Value &
"," & ActiveCell.Offset(0, 4).Value & "," & ActiveCell.Offset(0,
5).Value
Print #1, Output
ActiveCell.Offset(1, 0).Select
Loop
Close #1
End Sub
|