LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 140
Default 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
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Writing a macro in Excel that Refreshes External Imported Text File [email protected] Excel Programming 0 August 17th 07 08:29 PM
Open external data (varying file names) and closing file once data is retrieved Corrie Excel Programming 2 December 31st 06 09:56 PM
Writing streaming data to txt file [email protected] Excel Programming 3 June 1st 06 05:01 PM
writing data to a tab delimited text file? festdaddy Excel Programming 2 November 9th 05 09:41 PM
Writing to a text file some data Tom Ogilvy Excel Programming 0 September 9th 04 04:25 PM


All times are GMT +1. The time now is 07:03 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"