![]() |
automatic file name
Hi
I have one problem with excel: my data are beeing colected real time and from time to time I want to backup them. I made such thing: Dim ff as Integer ff = FileFree() Lastrecord = 1000 FirstCol = 1 LastCol = 5 Open "C:\arch\backup.txt" For Append as ff for r = 5 to Lastrecord for C = FirstCol To LastCol if C=1 Then Print #ff, Format(Cells(r,C), "yyyy-mm-dd") & vbTab; Elseif C = 2 Then Print #ff, Format(Cells(r,C), "hh:mm:ss") & vbTab; Else Print #ff, Cells(r,C) & vbTab; End if Next C Print #ff; Next r Close ff The only thing is how to force excel that each time Export procudure is call the name of the file (backup.txt) different?! :) thanks for help ;) |
automatic file name
You shouldn't because you are Appending to the same file.
If you mean you want to create a new file each time then keep a counter on the sheet, Range("BackUpCount") and increment each time. Range("BackUpCount").Value=Range("BackUpCount").Va lue+1 Open "C:\arch\backup" & Range("BackUpCount").Value & ".txt" For Output as ff NickHK "bratek" wrote in message oups.com... Hi I have one problem with excel: my data are beeing colected real time and from time to time I want to backup them. I made such thing: Dim ff as Integer ff = FileFree() Lastrecord = 1000 FirstCol = 1 LastCol = 5 Open "C:\arch\backup.txt" For Append as ff for r = 5 to Lastrecord for C = FirstCol To LastCol if C=1 Then Print #ff, Format(Cells(r,C), "yyyy-mm-dd") & vbTab; Elseif C = 2 Then Print #ff, Format(Cells(r,C), "hh:mm:ss") & vbTab; Else Print #ff, Cells(r,C) & vbTab; End if Next C Print #ff; Next r Close ff The only thing is how to force excel that each time Export procudure is call the name of the file (backup.txt) different?! :) thanks for help ;) |
automatic file name
thx very much works perfectly!! :)
|
All times are GMT +1. The time now is 11:59 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com