+ Reply to Thread
Results 1 to 6 of 6

Help with VB code to simplify a BoM

  1. #1
    Registered User
    Join Date
    08-26-2019
    Location
    Sweden
    MS-Off Ver
    365
    Posts
    3

    Help with VB code to simplify a BoM

    Hello,

    New to VB code but know this is fully doable :). Would appreciate some help in the right direction

    I have a list/BoM that contains single parts and assemblies. Some assemblies are manufactured, some are purchased in a finished state but the BoM describes its content anyway.

    I want the script to go through row by row and check a specific column.
    If it finds a part that is "Purchased" it should keep it, if it has no sub-levels.
    If a part is "Purchased" and has lower levels beneth it it should delete those entire rows until it finds the next part on the same level.
    If it finds a part that is "Manufactured" with sublevels that is Ok and it should just leave it.

    In the attached example, it should fint that Part with name "G" is an assembly that is purchased and delete its content row 10-24(part H-V).

    Text below, image attached.

    Level P/N Part name Type
    1 xxxxx Top level
    2 xxxxx A Purchased
    2 xxxxx B Purchased
    2 xxxxx C Purchased
    2 xxxxx D Purchased
    2 xxxxx E Purchased
    2 xxxxx F Purchased
    2 xxxxx G Purchased
    3 xxxxx H Purchased
    3 xxxxx I Purchased
    3 xxxxx J Purchased
    3 xxxxx K Purchased
    3 xxxxx L Purchased
    3 xxxxx M Purchased
    4 xxxxx N Purchased
    4 xxxxx O Purchased
    4 xxxxx P Purchased
    4 xxxxx Q Purchased
    4 xxxxx R Purchased
    4 xxxxx S Purchased
    4 xxxxx T Purchased
    4 xxxxx U Purchased
    4 xxxxx V Purchased
    2 xxxxx W Manufactured
    3 xxxxx X Purchased
    3 xxxxx Y Purchased


    Some help is greatly appreciated.
    Attached Images Attached Images
    Last edited by davida.88; 09-12-2019 at 02:25 AM. Reason: Solved!

  2. #2
    Forum Expert WideBoyDixon's Avatar
    Join Date
    10-03-2016
    Location
    Sheffield, UK
    MS-Off Ver
    365
    Posts
    2,182

    Re: Help with VB code to simplify a BoM

    Give this a try:

    Please Login or Register  to view this content.
    WBD
    Office 365 on Windows 11, looking for rep!

  3. #3
    Forum Expert dangelor's Avatar
    Join Date
    09-06-2011
    Location
    Indiana, USA
    MS-Off Ver
    365 Pro Plus
    Posts
    2,274

    Re: Help with VB code to simplify a BoM

    Possibly...
    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    08-26-2019
    Location
    Sweden
    MS-Off Ver
    365
    Posts
    3

    Re: Help with VB code to simplify a BoM

    Impressive quick work WBD and dangelor!

    Both seem to work just fine. I was more familiar with the Do While loop since that was what i was trying to code myself. Both of the run the row - 1 thing that i noticed is really important in excell, if not i run the risk of skipping cells that needs checking since the rows rename themseves after the delete.

  5. #5
    Forum Expert dangelor's Avatar
    Join Date
    09-06-2011
    Location
    Indiana, USA
    MS-Off Ver
    365 Pro Plus
    Posts
    2,274

    Re: Help with VB code to simplify a BoM

    Good luck!

  6. #6
    Registered User
    Join Date
    08-26-2019
    Location
    Sweden
    MS-Off Ver
    365
    Posts
    3

    Re: Help with VB code to simplify a BoM

    It ran a very large list without issues. Both scripts rendered the exakt same result and took approximately the same amount of time!

+ 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. [SOLVED] Can I simplify this code?
    By pbexcel in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 08-23-2019, 03:55 AM
  2. [SOLVED] Simple VBA code to convert text to number (simplify/fix current code)
    By kenenthpaul0401 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-26-2018, 10:47 AM
  3. [SOLVED] simplify code VBA
    By nizar2016 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-10-2016, 10:48 AM
  4. [SOLVED] simplify vba code
    By wyldjokre69 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-11-2014, 10:01 AM
  5. [SOLVED] Simplify VBA Code
    By Sky188 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-28-2012, 02:31 PM
  6. [SOLVED] How can I simplify this code?
    By etuckram in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 07-26-2012, 05:04 AM
  7. [SOLVED] Simplify Code
    By Soniya in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-09-2006, 01:59 PM

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