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
|