Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 989
Default update a txt file if dta is new

In A5 I input a name on a daily basis, I am trying to write a macro that will
take the data in A5 and put it in a new line in a text file located at
c:/temp/list.txt
I will need to check first if the name is already there (there is only one
name per line) and if it is there not to add it again.
Can that be done.
Many thanks
Mark
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 80
Default update a txt file if dta is new

Mark,

Try this:

Sub Append_Line()
Dim vFile As String
Dim vLine As String
Dim vNewLine As String
Dim vFound As Boolean
vFile = "C:\Temp\List.txt"
vNewLine = Range("A5").Value
vFound = False
Open vFile For Input As #1
Do Until EOF(1)
Line Input #1, vLine
If vLine = vNewLine Then
Close #1
Exit Sub
End If
Loop
Close #1
Open vFile For Append As #1
Print #1, vNewLine
Close #1
End Sub

HTH,
Nikos

"mark" wrote in message
...
In A5 I input a name on a daily basis, I am trying to write a macro that

will
take the data in A5 and put it in a new line in a text file located at
c:/temp/list.txt
I will need to check first if the name is already there (there is only one
name per line) and if it is there not to add it again.
Can that be done.
Many thanks
Mark



Reply
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
update the hyperlink in file after changing the file name Bel71 Excel Worksheet Functions 3 May 11th 10 03:47 PM
Macro to pull data from another file - update name of file Don Excel Discussion (Misc queries) 2 February 10th 09 03:31 PM
i want to update one excel file the other one update automaticaly Basant New Users to Excel 1 December 16th 06 12:50 AM
Automatic update of links in destination file when source file mo. Brucgil Excel Discussion (Misc queries) 0 December 2nd 04 04:07 PM
Automate open file, update links, run macro, close and save file Geoff[_7_] Excel Programming 2 August 26th 03 10:13 PM


All times are GMT +1. The time now is 06:53 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"