+ Reply to Thread
Results 1 to 9 of 9

Trouble with CSV file - data automation

  1. #1
    Registered User
    Join Date
    10-14-2009
    Location
    Switzerland, Geneva
    MS-Off Ver
    Excel 2007
    Posts
    3

    Trouble with CSV file - data automation

    Hi there,


    I am new on this forum, and I hope I could find the help I need on my excel issue.

    Here is the background:

    I need to create a CSV file where all data have to be displayed in 4 columns: A=Product / B=Geography / C=Account / D=Data.
    My source file has 3 different dimensions, 2 dimensions are already displayed in columns (Product / Account) and 1 dimension is displayed in a row (Geography).

    My question is this one: how can I tell Excel to create a CSV file when I have dimensions and data differently displayed in my source file? Is there a mean that I can use to simplify the creation of a CSV, by doing some formulas/macros?

    Actually, the only solution I have found is the useof an Offset formula for the column creation in the CSV and the use of an Array formula (Sumproduct) for the data input in the CSV. However, when I used my methodology, I came up with a huge file and the number of rows in the CSV is up 65K. Would you know a good solution here to reduce the amount of rows, and to automatise the calculation process?

    Please note that I am not at all familiar with Macros - but I am wondering if the use of Macros would be a good option here...?

    See below an example of how the data are displayed in my different files (Source File and CSV file)

    database example.jpg

    I use MS Excel 2007, ASAP utilities on Windows XP

    Any help would be highly appriciated!

    Many thanks,

    PowerExcel
    Last edited by PowerExcel; 10-14-2009 at 04:30 PM. Reason: remove tables example and add image file

  2. #2
    Forum Expert
    Join Date
    08-27-2008
    Location
    England
    MS-Off Ver
    2010
    Posts
    2,561

    Re: Trouble with CSV file - data automation

    Are you needing to do this regularly, or once only?

  3. #3
    Registered User
    Join Date
    10-14-2009
    Location
    Switzerland, Geneva
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: Trouble with CSV file - data automation

    I would need to do it on regular basis, at least once per month...

    In fact, my real need is to create a Database Table from a Summary Table: The opposite operation of the regular Excel's pivot table feature.

    I think I have found a beginning of answer over the web.

    http://spreadsheetpage.com/index.php...summary_table/

    Just need now to understand if I can modify the below code on VBA where I could get in final a database file with more than 3 columns...would you know?

    Please Login or Register  to view this content.
    Last edited by PowerExcel; 10-15-2009 at 06:07 AM. Reason: adjust code format

  4. #4
    Forum Expert
    Join Date
    08-27-2008
    Location
    England
    MS-Off Ver
    2010
    Posts
    2,561

    Re: Trouble with CSV file - data automation

    Well... please use code tags (edit - go advanced - select code - hit # button)

    After that, I'm a big fan of using database tools (Access?) for database operations - Excel is designed for pivot tables etc. - i.e. what you have already said is the opposite of what you're trying to do.

    If your data is literally as you describe (two columns to one) I could write a quick macro, but I don't have XL07 and am wary of create such enormous row counts. Caveats made,if you confirm your data is laid out exactly as per first post, I will write a test script and you can try it out.

    CC

  5. #5
    Registered User
    Join Date
    10-14-2009
    Location
    Switzerland, Geneva
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: Trouble with CSV file - data automation

    In fact in my 1st post, I haven't shown the database correctly. See now the image I ve just uploaded in the 1st post.

    Have just corrected the code format in the 2nd post

  6. #6
    Forum Contributor
    Join Date
    01-18-2005
    Location
    Auckland New Zealand
    MS-Off Ver
    Office Professional 2007
    Posts
    295

    Re: Trouble with CSV file - data automation

    Try the attached workbook, which has a formula solution.

    Regards
    Mike
    Attached Files Attached Files

  7. #7
    Forum Expert
    Join Date
    08-27-2008
    Location
    England
    MS-Off Ver
    2010
    Posts
    2,561

    Re: Trouble with CSV file - data automation

    130k indirect formulae (volatile)... compounded with ifs?

    Revised formulae below, but recommend macro beneath:

    Revised formulae for formula-solution, not recommended:
    F2=INDEX(A:A,ROW(4:4)/2)
    F3=INDEX(B:B,ROW(4:4)/2)
    H2=INDEX(C$1:D$1,MOD(ROW(2:2),2)+1)
    H3=INDEX(C:D,ROW(4:4)/2,MOD(ROW(2:2),2)+1)

    Please Login or Register  to view this content.
    CC

  8. #8
    Forum Contributor
    Join Date
    01-18-2005
    Location
    Auckland New Zealand
    MS-Off Ver
    Office Professional 2007
    Posts
    295

    Re: Trouble with CSV file - data automation

    Morning CC

    Thanks for the formula improvements- I appreciate that using indirect(...) a lot is not best practice, but it worked, a least on a small scale . I like your use of Index to pick up the data headers.

    Regards
    Mike

  9. #9
    Forum Expert
    Join Date
    08-27-2008
    Location
    England
    MS-Off Ver
    2010
    Posts
    2,561

    Re: Trouble with CSV file - data automation

    Cheers,
    You did the logic, I just tidied it up

    One of the nifty things about index is it automatically INT()s the row/column refs (as I understand it, it only accepts the arguments as integers, so they're automatically truncated)

    CC

+ 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