Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
Is it possible for me to read a text file (just contains a number) an write the number to a cell and then increment that number and save tha back into the text file? Regards, Sanja -- Message posted from http://www.ExcelForum.com |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
It's possible, but you don't need to do that much work.
Option Explicit Sub testme01() Dim myNumber As Long Dim myLine As String Dim myFileName As String Dim FileNum As Long myFileName = "C:\my documents\excel\text.txt" FileNum = FreeFile 'read previous number: If Dir(myFileName) = "" Then 'not found MsgBox "File is missing!" Exit Sub Else Close FileNum Open myFileName For Input As FileNum Do While Not EOF(FileNum) Line Input #FileNum, myLine myNumber = Val(myLine) Loop Close FileNum End If myNumber = myNumber + 1 Open myFileName For Output As FileNum Print #FileNum, myNumber Close FileNum End Sub "sanjay <" wrote: Hi, Is it possible for me to read a text file (just contains a number) and write the number to a cell and then increment that number and save that back into the text file? Regards, Sanjay --- Message posted from http://www.ExcelForum.com/ -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
load a CSV file and have it take all fields as text | Excel Discussion (Misc queries) | |||
is it possible to execute write to the fields in another .xsl form a macro in another .xsl? e.g. some way to load another .xsl into an .xsl macro and write to its data? | Excel Worksheet Functions | |||
Can I load text file into Excel seting field delimter using cmd li | Excel Discussion (Misc queries) | |||
how to write other language in text file from VBA | Excel Programming | |||
write a line from Excel to a text file | Excel Programming |