+ Reply to Thread
Results 1 to 6 of 6

looping code

  1. #1
    Registered User
    Join Date
    01-09-2009
    Location
    Raleigh, NC
    MS-Off Ver
    Excel 2003
    Posts
    4

    Need help looping vba

    Hi. I am new at all this, and have had tons of help with the below macro, but now we're needing someone to maybe review it and see where we've gone wrong. I am fully lost at this point, so any help would be greatly appreciated.

    The left table is partial from the workbook that this macro will be saved to.
    The right table is in another workbook called directory.xls (used for reference by the macro).

    I’ve entered the variables used in the code to the tables for reference.

    This Sheet
    B.............D
    pnum........qty

    Directory.xls
    A..........B........C
    dnum.....dfol.....file


    What we’re trying to do with the macro is :-

    1. look at “pnum”, if this cell is blank then the macro ends.

    2. If “pnum” contains an entry then it looks to “qty”, if this is blank or 0 then it looks at pnum in the next row.

    3. When it finds “qty” greater than 0 it needs to search “dnum” in the directory to find an exact match for “pnum” exiting if no match is found. (thinking message and back to next row in #2 instead).

    4. It then needs to take the text of “dfol” in the same row and pass that to the next part of the code as the source directory for the file copy, with “file” being the filename to copy.

    5. After this is done it then needs to return to the top of the loop and look at the next entry in #2

    Please Login or Register  to view this content.
    Last edited by Mayaleigh; 01-09-2009 at 10:26 AM.

  2. #2
    Registered User
    Join Date
    03-16-2004
    Posts
    65
    If you could please post your files it would greatly help to expatiate getting a clean working answer to your question.
    Last edited by TyeJae; 01-09-2009 at 10:36 AM.

  3. #3
    Registered User
    Join Date
    01-09-2009
    Location
    Raleigh, NC
    MS-Off Ver
    Excel 2003
    Posts
    4
    DATA SHEETS folder as Directory.xls
    is the lookup table for reference
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    01-09-2009
    Location
    Raleigh, NC
    MS-Off Ver
    Excel 2003
    Posts
    4
    Books1 is a modified version of the whole bill of materials so that it could be small enough to post here.
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    03-16-2004
    Posts
    65
    Here is where I am at so far. I'm not quite sure what else you want the macro to do...

    Put this bit of code in a module named module1

    Please Login or Register  to view this content.
    Now put the next bit of code in your workbook

    Please Login or Register  to view this content.
    This should loop through everything for you. Explain a little bit further if you need help with anything more.

  6. #6
    Registered User
    Join Date
    01-09-2009
    Location
    Raleigh, NC
    MS-Off Ver
    Excel 2003
    Posts
    4
    Thanks so much, I'm trying to wrap my head around that now
    This is kind of a description of what i'm trying for:

    All blocks in my AutoCAD documents have been embedded with attributes that reflect each part: my inventory number, the manufacturer, a description, and so on. This information goes into an excel spreadsheet, it’s dumped onto one sheet and 3 other sheets take that information and automatically update the other pages for a bill of materials, fuse table etc. (That's what book1 shows). From this information I need to manually collect cut sheets for each part in the project from a data base of cut sheets. What I’m trying to do, is run the macro from the sheet “Bill of materials” when there is a count for an item, I want it to be seen by the macro and go out and copy that associated cut sheet to the file the .xls is located.

+ 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