+ Reply to Thread
Results 1 to 11 of 11

Create a txt file from the data in the excel sheet

  1. #1
    Registered User
    Join Date
    02-07-2015
    Location
    DLA
    MS-Off Ver
    2003/2007
    Posts
    8

    Create a txt file from the data in the excel sheet

    Hello,
    I need your help to export to a text file the information in the sheet "Detail".
    - The Head of the text file is in my script. Only the date in that header changes, it is the day wich the text file is created.
    - Records detail (0602): There are many records as rows in the Sheet.
    - A total record (0802): This is the last of the table and it is described only once in the text file.

    The empty spaces are part of the txt file and space should match the field length considering a space is a character.
    As below

    The reserve1 field = String (8, Chr (160).

    Sorry for my English.

    Regards.
    Attached Files Attached Files

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Create a txt file from the data in the excel sheet

    Hello Nyepalo,

    Welcome to the Forum!

    This macro will output the worksheet data to a text file. Pass the file path and name when you call the macro.

    Example:
    Please Login or Register  to view this content.
    Macro Code
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Registered User
    Join Date
    02-07-2015
    Location
    DLA
    MS-Off Ver
    2003/2007
    Posts
    8

    Re: Create a txt file from the data in the excel sheet

    Hi Ross,

    Thank you very much for your speed, it's perfect, exactly what I was looking for, thank you again

    I want also to integrated the header line in the file.txt. The Header line is one record and contains data that does not change except for the date of file creation witch is in the jjmma. I tried to fit it in your script, I didnt succeeded.
    See my code
    Please Login or Register  to view this content.
    Regards.
    Attached Files Attached Files

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Create a txt file from the data in the excel sheet

    Hello Nyepalo,

    Your change was close to correct. Here is the macro with your header code added. The header appears to be longer than 160 characters. Is it supposed to wider than the other lines?

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    02-07-2015
    Location
    DLA
    MS-Off Ver
    2003/2007
    Posts
    8

    Re: Create a txt file from the data in the excel sheet

    Hi Ross,
    The header is not more than 160 caracters.

    The Script should be :
    Please Login or Register  to view this content.
    I must add the current date in the header like ddmma :
    Please Login or Register  to view this content.
    But is not corect because the result is 925 it must be 09025.

    Please Login or Register  to view this content.
    Thanks.

  6. #6
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Create a txt file from the data in the excel sheet

    Hello Nyepalo,

    Is the jjmma today's date? That is the date the macro is run? Or does this date come from someplace else in the workbook?

  7. #7
    Registered User
    Join Date
    02-07-2015
    Location
    DLA
    MS-Off Ver
    2003/2007
    Posts
    8

    Re: Create a txt file from the data in the excel sheet

    That is the date the macro is run ? Yes

  8. #8
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Create a txt file from the data in the excel sheet

    Hello Nyepalo,

    This should work...
    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    02-07-2015
    Location
    DLA
    MS-Off Ver
    2003/2007
    Posts
    8

    Thumbs up Re: Create a txt file from the data in the excel sheet [Solved]

    Hello Ross,

    You're fantastic, everything is in order as I wanted. Thank you very much

    God bless you.

  10. #10
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Create a txt file from the data in the excel sheet

    Hello Nyepalo,

    You're welcome.

  11. #11
    Registered User
    Join Date
    02-07-2015
    Location
    DLA
    MS-Off Ver
    2003/2007
    Posts
    8

    Re: Create a txt file from the data in the excel sheet

    Hi Ross,

    I still need your precious help for my text file coming from the data in the Worksheet.
    The text file contains the return line after the total record, I want this return line automatically deleted when creating texte file. How can I do ?

    Regards.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Create txt file from excel sheet
    By hkbhansali in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 04-09-2014, 09:11 AM
  2. Automatically create file and fill in three cells from data in csv or other excel file
    By jamielpeters in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 04-16-2013, 06:19 PM
  3. Create a *.txt file from an excel sheet
    By Woodbags in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-07-2013, 08:36 AM
  4. Filter, copy filtered data into another sheet, create a file of that sheet..
    By titushanke in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 06-17-2012, 02:26 PM
  5. Replies: 3
    Last Post: 05-03-2012, 10:56 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1