This is ripe for simply recording the steps. The playback will be pretty straightforward, and the learning will be most instructive.
already tried but the size of the two txt files change and by recording i am restricting to appending to a particular range of fields - ie i "paste" to cells Ax:Dx
i need it generic so it appends always to the end no matter what size
!!!
ta, any sugestions????
Conor, can you post your recorded macro (then I can change it so it is dynamic)?
BarrieBarrie Davidson
Hi Conor,
Here is a simple macro that does what you describe. The two files must be in the Excel working (default) directory. If you are not currently in the working directory, you can set it by doing an Excel File -> Open, browse to the directory, then Cancel out of the open.
There is no length restriction on the file sizes with this macro.
Happy merging.
Damon
Sub MergeFiles()
' This routine concatenates two files, input1.txt and input2.txt, into
' input1.txt that contains the original input1.txt followed by all but the
' first 12 records of the input2.txt file
Dim InRec As String
Dim iRec As Long
Open "Input1.txt" For Append As #1
Open "Input2.txt" For Input As #2
' copy Text2.txt, skipping 1st 12 records
For iRec = 1 To 12
Line Input #2, InRec
If EOF(2) Then GoTo Done
Next iRec
'write remainder of records
Do
Line Input #2, InRec
Print #1, InRec
Loop Until EOF(2)
Done:
Close 'all files
Beep
MsgBox "Merge complete, Input2.txt appended to Input1.txt", _
vbInformation, _
"Merge Status"
End Sub