+ Reply to Thread
Results 1 to 4 of 4

Macro for re-arranging data from a csv-file

  1. #1
    Registered User
    Join Date
    10-07-2010
    Location
    Delft, Netherlands
    MS-Off Ver
    Excel 2010
    Posts
    6

    Macro for re-arranging data from a csv-file

    Hi there,

    I was wondering if anyone can help me with the following. I have an csv file with invoice information information that should be shown in a different order. The csv-file has three types of rows:
    - The first row contains the header information (K)
    - The following rows contain the item information (P).
    -The last row has the total amount information (S), which I do not need

    This csv-file needs to be created into an XML file; I already have a vbscript for this. The problem is that in order to be able to run this script the data should be in a certain order. The format being that one row contains the header information and the item information instead of two separate rows. If the invoice contains more than one item, an additional row is added, including the header information. Thus:
    - The first 18 fields (row1-Type K) of the csv-fille contains the header information. These should be copied to the first row of the xml-conversion sheet.
    - The following 14 fields (row2 - type P) of the csv-file contains the item information. These should be copied after the first 18 fields
    - If there are more items, then the first two steps should be repeated (!)
    - The following 7 fields (after type P -type S) should be ignored.

    I have attached an Excel file with how an example of how it should work.

    Could anyone help?
    Attached Files Attached Files

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Macro for re-arranging data from a csv-file

    In the example uploaded, on the sheet CSV-file does the data demonstrated in row1 actually exist or did you include that just to help us read it? Does the sheet Desired Output really need rows 1 and 2 as shown or is the rest all you need?
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Registered User
    Join Date
    10-07-2010
    Location
    Delft, Netherlands
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Macro for re-arranging data from a csv-file

    Hi JBeaucaire,

    -csv-file: Indeed, row one is not in the actual csv-file, i added that manually
    - Desired-output: Yes, row 1 and 2 are merely for explanatory purposes

  4. #4
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Macro for re-arranging data from a csv-file

    Try this:
    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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