Writing Data to an External File
Hi Souny
This worked for me. Just change the path to suit. Adds the data from
the userfile.xls to the bottom of the used range in the trackfile.xls.
Take care
Marcus
Option Explicit
Option Compare Text
Sub Open_Import1()
Dim oWbk As Workbook
Dim sFil As String
Dim sPath As String
Dim twbk As Workbook
Dim lr As Integer
Dim strFullName As String
Set twbk = ActiveWorkbook
Application.DisplayAlerts = False
Application.ScreenUpdating = False
twbk.Sheets("Sheet1").Range("A1:B1").Copy
sPath = "R:\" 'Cell B2 of Cal sheet, location of files
ChDir sPath
sFil = Dir("trackfile.xls") 'change or add formats
strFullName = sPath & sFil
Set oWbk = Workbooks.Open(strFullName)
lr = oWbk.Sheets("Sheet1").Range("A" & Rows.Count).End(xlUp).Row + 1
oWbk.Sheets("Sheet1").Range("A" & lr).PasteSpecial xlPasteValues
oWbk.Close True 'close the workbook, saving changes
sFil = Dir
End Sub
|