+ Reply to Thread
Results 1 to 5 of 5

Need to make txt sheet with specific fields taking up a specific number of spaces.

  1. #1
    Registered User
    Join Date
    08-01-2012
    Location
    United States
    MS-Off Ver
    2010
    Posts
    2

    Need to make txt sheet with specific fields taking up a specific number of spaces.

    Hello hello! I have data I ultimately need to be in a .txt file that is sent over FTP to a database. Each space counts, and each field has a specific amount of spaces that need to be there before the next field is entered. There is software to correctly do this, but it has no option of importing files to pull data from, all the data has to be manually typed in. Right now I use a keyboard and mouse macro to copy and paste data from my excel sheet to the software, but would like to have excel just go ahead and write the data file for me.

    Here is a link to the description of what the requirements are:

    http://www.myfloridalicense.com/dbpr...uctions_09.pdf

    it is on pg 16

    Each table and spaces talked about within are 1 line. The next table is the next line down.
    Last edited by ajca01; 08-01-2012 at 11:19 AM. Reason: more info

  2. #2
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,520

    Re: Need to make txt sheet with specific fields taking up a specific number of spaces.

    @ajca01

    I have done these types of files for our EDI Invoices for our company to be able to upload Invoices to stores databases. I have attached a sample of a macro to add spaces to the end of the field. Now I dont know if any of your fields will be bigger then the field size but I can handle that also. Just would need to know how you want to handle it. Ex: If field size is 4 and the value is MikeJ I can get Mike and add it to the txt file or throw up error message.

    Heres a small sample,

    Space Sample.xls
    Last edited by mike7952; 08-01-2012 at 11:52 PM.

  3. #3
    Registered User
    Join Date
    08-01-2012
    Location
    United States
    MS-Off Ver
    2010
    Posts
    2

    Re: Need to make txt sheet with specific fields taking up a specific number of spaces.

    I was able to use this formula to make each field the length I need: =LEFT(Sheet2!A4&REPT(" ",7),7). Where the 7 is whatever length you need the specific field to be. However, making excel do what is needed seems to keep becoming more complex. Each line is specific to its place relative to other lines, each type of line has a specific number:

    1 = Provider Information
    2 = Class Information
    3 = Student License Information
    4 = How many attendees for this specific class information ( between this 4 and the previous 2).
    5 = total amount of lines in all of the data sheet

    There are different types of licenses, each needed to be under a new class record (for unknown reason). A report layout could look like so:
    (going to separate fields with ":" for viewing purposes, they are not in the real data sheet)

    1:9999999:PROVIDER NAME :9999:G20133
    2:1234567:08/02/2012:CLASS NAME
    3:BU:2222222 :JACKSON, JACK
    3:BU:3333333 :DOE, JOHN
    4:2
    2:1234567:08/02/2012:CLASS NAME (SAME AS BEFORE)
    3:CC:1111111 :REGO, THOMAS
    4:1
    2:1234567:08/02/2012:CLASS NAME (SAME AS BEFORE)
    3:CG:4444444 :TILLMAN, RAY
    3:CG:5555555 :GATES, BILL
    3:CG:7777777 :WAYNE, JOHN
    3:CG:6666666 :COMPTON, MICHAEL
    4:4
    5:15 :[email protected]

    I feel I would need a macro that would copy and paste each line, repeating line 3 for every consecutive same license type in the column. When it hits a new license type it pastes lines 4(with how many line 3's it just pasted) then paste line 2, then keep pasting line 3's again. If anyone feels up for the challenge, it would be greatly appreciated.

  4. #4
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,520

    Re: Need to make txt sheet with specific fields taking up a specific number of spaces.

    Can you make up a mock workbook example of what the workbook would look like before and after the macro would be run.

  5. #5
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,520

    Re: Need to make txt sheet with specific fields taking up a specific number of spaces.

    @ajca01,

    Here's an example that will create a txt file. First save the attatched workbook to your computer. The output of the txt file will be in the same folder as the workbook folder. Without knowing the structure of your Excel file that you are needing manipulated into a text file its hard to make an example. So this should give you an idea, also its only an example of Record Type 1 (Provider Record).

    Space Sample_v3.xls

    Let me know more of your data structure in your workbook and Im sure I can make your life a little easier.

    Thanks Mike
    Last edited by mike7952; 08-02-2012 at 12:51 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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