+ Reply to Thread
Results 1 to 6 of 6

Bill of Materials Comparison Macro

  1. #1
    Registered User
    Join Date
    09-15-2008
    Location
    White Lake, Mi.
    Posts
    18

    Bill of Materials Comparison Macro

    I am working on a macro that will compare multiple Bill of Materials for work.
    I have included a small section of my spreadsheet after I have performed several operations on it already and this is where I get stuck on a decent way to proceed.

    Background:
    Each usage starts as a separate sheet with its corresponding BOM.
    Copy each BOM onto the same (Master) Worksheet.
    Sort by Part Number (ascending), UPC (Ascending), and Usage (Ascending)

    I need to compare each line to ensure that the Part Number, UPC, FNA, and QTY are the same. If they are I want to condense the line up to have x marks in the line for the first occurrence of that Part/UPC/FNA/QTY combination.

    I am attempting to rewrite this macro because it was only capable of comparing 10 usages in the beginning. I am trying to make it variable so that it can compare any number of usages. I currently have it set to determine how many usages there are by performing a count of the worksheets contained in the workbook.

    Any help would be greatly appreciated.
    If need be, I can provide the code that was used to get this far, and I can also provide the code for how it used to be compared and condensed.

    I Have attached a before and after example of what I am looking at and what I am trying to do.
    Writing this in Excel 2003 BTW.

    Thanks
    Rick
    Attached Files Attached Files
    Last edited by r0cket88; 09-19-2008 at 08:51 AM. Reason: forgot to sign it.

  2. #2
    Forum Contributor
    Join Date
    03-25-2008
    MS-Off Ver
    Excel, Outlook, Word 2007/2003
    Posts
    245
    To get you started. Although desc3 and desc5 are different from your example. This code will copy the value if the destination isn't an x.
    Please Login or Register  to view this content.
    Charlize

  3. #3
    Registered User
    Join Date
    09-15-2008
    Location
    White Lake, Mi.
    Posts
    18
    Thanks for the Code, but I have a few issues with it.
    I went ahead and tired it, and ran into a few errors.

    The third part in my list, the usage on it is only #'s 19,20,23 and 24.
    However when it copied the row over it copied "x" into all of the columns.

    Some of my parts have the same number, and the same qty, but different UPC and FNA. These need to have seperate rows to indicate that the same part is used in more than one place in the process. I think this is what you are getting at with the comment about usage 3 and usage 5. I need to make sure I catch these parts in multiple locations.

    Also, I don't see an easy way to make this work for a variable number of usage columns. That may be becuase I am new to coding VBA, or it may be because I haven't explored the use of arrays enough yet.

    What if I were to copy the usage column to column A and the numbered usage columns to columns B to however many I have. Then I can count the number of uniqe parts, count the amount of each duplicate part number and loop through each using offsets to copy the x up to the appropriate row and column. Then I can just format the sheet back to what it is supposed to look like.

    This solution, may not be quite as efficient, but I think it should work.

    Thanks for the help. I will take a closer look at this code too and see If I can make it work for my purposes. I need to do some research so I understand how your code works before I try to change it.

    Rick
    Last edited by r0cket88; 09-22-2008 at 07:38 AM. Reason: Spelling

  4. #4
    Registered User
    Join Date
    09-15-2008
    Location
    White Lake, Mi.
    Posts
    18
    Here is the code I used to get this far. The original code only allowed for the comparison of 10 assemblies. This code (updated by me) allowes for variable amounts of assemblies.

    Please Login or Register  to view this content.
    Last edited by r0cket88; 09-22-2008 at 08:00 AM.

  5. #5
    Forum Contributor
    Join Date
    03-25-2008
    MS-Off Ver
    Excel, Outlook, Word 2007/2003
    Posts
    245
    Put the next piece of coding in front of the line
    Please Login or Register  to view this content.
    and after
    Please Login or Register  to view this content.
    .
    Please Login or Register  to view this content.
    This will count the no of occurences of a certain description. It's still not clear how you determine which usage no gets an x and which level a -.

    I just copied the data of all the descriptions on one line. If an x was on usage 1 then the code makes sure that when you copy another line of the same description the 1st x doesn't get overwritten. To say it differently, every column from usage 1 to usage 25 (for the same description) is copied over if the destinationsheet doesn't have an x at that location.

    Charlize

  6. #6
    Registered User
    Join Date
    09-15-2008
    Location
    White Lake, Mi.
    Posts
    18
    Here is an example of how the usage comes into play.

    Column K is a designator that determines usage.
    So on Row 2 cell K2 usage is listed as one. This means that the column M (labeled as usage 1) gets an "x" in it. So Column K is the qualfier for what column gets an "x".

    I Appreciate all your help Charlize.

    I have reordered the columns to try and make comparing with if then statements a little easier and I have attached an example of the re-order in the excel spreadsheet.

    Here is the code I am currently using to sort this data:
    Please Login or Register  to view this content.
    It works ok for the sections that are one line for each usage, but when I get into situations where I have the same part number but different usage locations (indicated by the UPC and FNA) or different QTY's then I don't know how to handle it.
    Attached Files Attached Files

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. How to splitt texts into words? (collecting word and compounds)
    By wali in forum Excel Programming / VBA / Macros
    Replies: 53
    Last Post: 02-03-2008, 04:06 AM
  2. vba to change macro file name
    By blackstar in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 12-02-2007, 12:14 AM
  3. Conditional formatting macro (highlight macro)
    By c991257 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-09-2007, 02:46 PM
  4. country finder lookup macro
    By theghost in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-07-2007, 10:41 PM
  5. Data Comparison between worksheets - Macro
    By masterp in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-26-2007, 10:26 AM

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