I need to edit a text file i.e add and update the data using the macro. I have a text file having thousands of records, a separate excel sheet which gives the mapping of data in text file. For example, a record in text file looks like:
ABCDNew Delhi India
The mapping excel sheet for this is as below:
Name 4
City 10
Country 10
Which means that the 1st four characters in record give the name, next 10 give city and next 10 give the country of a particular person and so on. Now, I have to edit a record (one or two fields) for a particular name and save it in same file. Also I have add a new record in the above specified format and then save the file.
The excel sheet just gives the mapping of the fields in the text file. It tells only the field lengths. As u can see in my question, the text is continuos without any delimiter in it. hence the excel sheet is used to identify the variuos fields in the text file. sample record is like:
ABCDDelhiIndia1100019876543210
and the mapping is:
Name 4 City 5 Country 5 PinCode 6 PhnNo 10
The mapping is same for all records in a file. Its just gives a way how the records can be read from a file.
Any Ideas on how can I do this in simplest way?