+ Reply to Thread
Results 1 to 5 of 5

VB code to calculate loading on equipment per Product

  1. #1
    Registered User
    Join Date
    01-06-2016
    Location
    Jerusalem, Israel
    MS-Off Ver
    13
    Posts
    6

    VB code to calculate loading on equipment per Product

    Hi.

    I have a bit complicated question (yet not sure if excel vba is the right tool or better to work with SAS).

    I have a list of machines with a time stamp for each time they are performing activity.

    i.e.

    07/31/2016 00:12:11 Machine-A Cup
    07/31/2016 00:12:21 Machine-A Dish
    07/31/2016 00:12:31 Machine-A Spoon
    07/31/2016 00:12:41 Machine-A Cup
    07/31/2016 00:12:51 Machine-A Cup
    07/31/2016 00:14:11 Machine-A Knife

    What I need is to add for each line few columns with how loaded the equipment was before this activity in the last hour.

    i.e.
    Time Eqp Prod Cup Dish Spoon
    07/31/2016 00:12:11 Machine-A Cup 3 7 9

    Any Idea?

    Thank you.
    Last edited by jeansboy1; 07-30-2016 at 05:22 PM.

  2. #2
    Forum Expert Crooza's Avatar
    Join Date
    10-19-2013
    Location
    Hunter Valley, Australia
    MS-Off Ver
    Excel 2003 /7/10
    Posts
    2,082

    Re: VB code to calculate loading on equipment per Product

    Hi.

    I meanto reply to this a few days ago but I got distracted on something else. You don't need VBA to solve this.

    Use a SUMPRODUCT in the following form

    =SUMPRODUCT(--(ABS($A3-$A$2:$A2)<1/24),--(D$1=$C$2:$C2))

    And see the attached file to see it in context
    Attached Files Attached Files
    Happy with my advice? Click on the * reputation button below

  3. #3
    Registered User
    Join Date
    01-06-2016
    Location
    Jerusalem, Israel
    MS-Off Ver
    13
    Posts
    6

    Re: VB code to calculate loading on equipment per Product

    Thank you Crooza for you answer.

    I managed to do it with similar way (CountIf).
    The problems are:
    1. I have 200000 rows in the file - so the excel cannot complete the task - I have to work with 1000 rows back for each row { =SUMPRODUCT(--(ABS($A1001-$A2:$A1001)<1/24),--(D$1=$C2:$C1001)) }
    2. The machine is producing many products (changing each time) - I thought it more for VB code - can't think how to calculate only the last 1 hour each time back rows and how to create a column for each product.

    Thank you.

  4. #4
    Forum Expert Crooza's Avatar
    Join Date
    10-19-2013
    Location
    Hunter Valley, Australia
    MS-Off Ver
    Excel 2003 /7/10
    Posts
    2,082

    Re: VB code to calculate loading on equipment per Product

    What is the maximum number of rows you'd expect in an hour? you only have to go back this many rows so don't lock the first array value. Simply have A1:A300 for example from row 301 onwards and you'll get a rolling 300 row array.

  5. #5
    Forum Expert Crooza's Avatar
    Join Date
    10-19-2013
    Location
    Hunter Valley, Australia
    MS-Off Ver
    Excel 2003 /7/10
    Posts
    2,082

    Re: VB code to calculate loading on equipment per Product

    Further to above post, upload your file and I'll see if I can create a VB solution if that's what you really want.

+ 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. Replies: 1
    Last Post: 06-14-2015, 10:06 PM
  2. [SOLVED] I wish to calculate the daily average usage for any given piece of equipment
    By IPDaily in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 08-22-2012, 09:52 PM
  3. Vba code to calculate the count of a column
    By Sonali Varma in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-24-2012, 07:45 AM
  4. [SOLVED] Userform Keeps loading after code is completed
    By lday75 in forum Excel General
    Replies: 1
    Last Post: 07-14-2012, 02:46 AM
  5. VBA code to calculate two column values automatically
    By jpruffle in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-10-2009, 04:31 PM
  6. ComboBox code running on loading
    By ekacan in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-02-2009, 03:48 PM
  7. Addins not loading when opening from code
    By Jack in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-15-2005, 06:45 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