Import a txt onto a sheet.

Post Reply
wwj
Posts: 2497
Joined: 27 Jan 2007 08:16

Import a txt onto a sheet.

Post by wwj »

Help.

https://stackoverflow.com/questions/112 ... xcel-sheet

My Example:

Code: Select all

Sub a_import()
    Dim wbI As Workbook, wbO As Workbook
    Dim wsI As Worksheet

    Set wbI = ThisWorkbook
    Set wsI = wbI.Sheets("modeledHead")  'Sheet where the modeled heads are import to.

    filePath = ActiveWorkbook.Path & "\dirTRg\"
    inputSheet = "1_hydrograph_x.dat"     ' Data file name without .csv extension.
    inputFile = filePath & inputSheet
    
    Set wbO = Workbooks.Open(inputFile)

    wbO.Sheets(1).Cells.Copy wsI.Cells

    wbO.Close SaveChanges:=False
    
End Sub
Post Reply