PDA

View Full Version : [SOLVED:] How to write last row update record in excel into txt file ?



clif
10-06-2016, 06:53 PM
Dear all,

How to write last row update record in excel into txt file,
the txt file is used for accumlating the data records.

Thank you very much!

SamT
10-07-2016, 06:26 AM
???

clif
10-07-2016, 06:50 PM
17292

i intend to know how to update just one row of data in excel to txt file?
I mean the steps
1.copy one row of data in excel
2.open the txt file which contains some previously saved string
3.open a new line in the txt file
4.then paste it in the txt file
5.save the txt file
6.close the txt file


open the old txt file and open a new line and copy the

mana
10-07-2016, 07:52 PM
Option Explicit

Sub test()
Dim v, s As String
Dim myPath As String

myPath = "C:\***\***\test.txt"


v = Range("a1").End(xlDown).Resize(, 3).Value
s = Join(WorksheetFunction.Transpose(WorksheetFunction.Transpose(v)), ",")


Open myPath For Append As #1
Print #1, s
Close #1

End Sub

clif
10-07-2016, 08:58 PM
What is the difference between write and print ?

mana
10-07-2016, 09:13 PM
try this.


Open myPath For Append As #1
Print #1, s
Write #1, s
Close #1

YasserKhalil
10-07-2016, 09:24 PM
I think Write treats output as string so in output you will notice quotations " " around the results , but Print doesn't do that