I think you have to open them separately, but after you open the second one,
just move it the same workbook as the first.

The last line in this code performs the move:

Sub sbTwoTextFiles()

'dimension variables

Dim wsDest As Worksheet


'open first text file

Workbooks.OpenText Filename:="C:\text1.txt", StartRow:=1, _
DataType:=xlDelimited, ConsecutiveDelimiter _
:=False, Tab:=False, Semicolon:=False, Comma:=False, Space:=True


'set worksheet variable to first text sheet

Set wsDest = ActiveSheet


'open second text file

Workbooks.OpenText Filename:="C:\text2.txt", StartRow:=1, _
DataType:=xlDelimited, ConsecutiveDelimiter:=False, Tab:=False, _
Semicolon:=False, Comma:=False, Space:=True


'move text file to sheet after first text file

ActiveSheet.Move After:=wsDest

End Sub




"ramki" wrote:

> hay any one help me in opening an existing txt files with a macro or
> VBA coding.
>
> like i have differrent txt files in differrent file if open those file
> each txt file will be opened in one excel but i want all of them to be
> opened in the same excel file but in differrent sheets.
>
> and one more thing if we open a text file in excel it will ask us for
> the coulumn and row breaks i want to skip that as my default delimitar
> is a space
>
> thank you
>
>