Results 1 to 19 of 19

Thread: Solved: Loops that write specific data to file

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    VBAX Regular
    Joined
    Sep 2010
    Posts
    28
    Location

    Arrow Solved: Loops that write specific data to file

    Hi all.
    I'm trying to create detailed report pages based on excel data.

    Here's a little view to the sheet:
    ht tp://i33.tinypic.com/2q8dpoi.jpg
    I've also attaced this sample if you want to work on it.

    First of all, I want the method to "remember" some coulmns by their titles (they'll be always the same), and "know" where to find the needed data.
    I guess it'll be several loops that search for "title" and strore the column indexes in variables. ("Business Name" into BusNameCol, "Sign Content" into SignContentCol, etc.)

    Now, I want a loop that runs on "Property ID" column (its index will be stored in PropIDCol).
    When the loop finds a "new" (not yet handled) value, it will:
    • * Create a new file, named as the property id value.
    • * Print to file, *only once*, some values like businnes name, owner name, etc. (their column indexes are stored)
    • * Print in a new line some other values, like sign content, width, height, etc. (their column indexes are stored)
    • * Loop on the rest of lines of the current handled "Property ID", and continue creating new lines for those same other values.
    NOTICE: Same property ids are not all in sequence! So it's not a simple "while" loop. It'll need to "collect" from the close range (let's say 50 lines).
    • * After that, it'll return to the "main" loop and move to the next "new" property id.
    For the method to know where to "return" to, my idea is to have a "check" column (its index in CheckCol). For every line the method handles, it'll put "1" in this column.
    It also will be good if I want to run the macro several times (if businesses are added in future), and not to have multiple report files.


    There is also line 12 in the picture, which doesn't have property and owner data, I think that in this case it will collect according to business name instead of property id.


    -------------------------------------------------------
    OUTPUT EXAMPLE:

    BusinessName: Paz | Owner ID: 510216054 | Property ID: 166143000003 | Owner Name: Paz Company Ltd. | Owner Address: P.O.B. 222 City

    (Sign Content | Width (cm) | Height (cm) | Rounded Area | Sign Address - Street | Sign Address - House | Sign Location)

    Tasty Yellow | 250 | 230 | 6 | rd. 434 | 21 | Display Window
    Paz (changing ads) | 90 | 60 | 1 | rd. 434 | 21 | Bulding Wall
    Paz (changing ads) | 90 | 60 | 1 | rd. 434 | 21 | Bulding Wall
    Price List | 120 | 60 | 1 | rd. 434 | 21 | Pole
    Paz | 80 | 60 | 1 | rd. 434 | 23 | Gas Station

    -------------------------------------------------------

    Thanks *A LOT* in advance for all the helpers!!!

    =-= MeiR =-=
    Last edited by MeiR_ct; 09-08-2010 at 02:56 AM. Reason: fixed output example

Posting Permissions

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