+ Reply to Thread
Results 1 to 11 of 11

Calculations with VBA: Sum Product and Rate Lookup

  1. #1
    Forum Contributor
    Join Date
    11-06-2021
    Location
    Tripoli
    MS-Off Ver
    Still using 2007 in 2023
    Posts
    289

    Wink Calculations with VBA: Sum Product and Rate Lookup

    Hello everyone,
    I hope you're all doing well today. I have a straightforward calculation that I intend to execute using VBA instead of direct sheet formulas. I'm specifically focusing on the yellow highlighted columns for this task.

    The given sheet already calculates the sum of working hours for each employee in every row.

    Now, I need to calculate the wage for each row, as indicated in column I. The formula in column I is simply (F2 * 24) * 0.54. Note that 24 is a constant, while the number 0.54 is variable based on the individual's hourly rate, as shown in table hour_rate (in Sheet2).

    So, I guess it is a VLOOKUP code that would retrieve the value of 0.54 from Sheet2. Hence, when this is achieved, I intend to perform a sum product operation on the values in column I, and the sum should consider only rows where the person is the same and has the same PRO. number simultaneously. These sum product values are calculated in column J.

    I've populated a few rows to illustrate the data. Please find below the VBA code for which a vba code may be added.


    Please Login or Register  to view this content.
    I appreciate your assistance in implementing these calculations using VBA.

    Thank you very much!

    Attached is my whole file as for your sole convenience.
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,352

    Re: Calculations with VBA: Sum Product and Rate Lookup

    Please Login or Register  to view this content.
    NOTE: changed table ("Rate_Tbl") in Sheet2 as VLOOKUP search parameter has to be FIRST in the range
    Attached Files Attached Files
    Last edited by JohnTopley; 12-21-2023 at 03:44 PM.
    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

  3. #3
    Forum Contributor
    Join Date
    11-06-2021
    Location
    Tripoli
    MS-Off Ver
    Still using 2007 in 2023
    Posts
    289

    Re: Calculations with VBA: Sum Product and Rate Lookup

    Hey John,

    Your solution is working perfectly. However, I anticipate a need to update the hourly rates in Sheet2. When I make these changes, I'd like to preserve the calculations based on the previous rates and only apply the new rates to future calculations. How can we manage this effectively?

  4. #4
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,352

    Re: Calculations with VBA: Sum Product and Rate Lookup

    You will need to add a "Date Effective" for each person [and or table] to your rate table which allows the comparison of the Start / End dates with this date.

    You need also to consider that a "Date Effective" COULD occur between "Start/End" dates so there are 2 rates to consider in this scenario .

  5. #5
    Forum Contributor
    Join Date
    11-06-2021
    Location
    Tripoli
    MS-Off Ver
    Still using 2007 in 2023
    Posts
    289

    Re: Calculations with VBA: Sum Product and Rate Lookup

    Hi John,
    I've understood your suggestion. In this scenario, I formulate a new table in Sheet2.
    I assume in my case that when the start date matches the effective date that i enter in cell F2 on Sheet2, that specific hourly rate should be considered.
    For any other cases, your previous code should handle it as before.

    To clarify, if there is no effective date specified, or if the start date is before the effective date, the original hourly rate remains effective.
    Only when there is a matching start date with the specified effective date should the new rate come into play.
    I appreciate your guidance on how to incorporate these adjustments.
    Thank you.
    Attached Files Attached Files

  6. #6
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,352

    Re: Calculations with VBA: Sum Product and Rate Lookup

    Why post a w/book that does not have the LATEST code produced [i.e that from post #2] ?

  7. #7
    Forum Contributor
    Join Date
    11-06-2021
    Location
    Tripoli
    MS-Off Ver
    Still using 2007 in 2023
    Posts
    289

    Re: Calculations with VBA: Sum Product and Rate Lookup

    Ah, you're right..here is the new updated workbook
    Attached Files Attached Files

  8. #8
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,352

    Re: Calculations with VBA: Sum Product and Rate Lookup

    Please Login or Register  to view this content.
    changed dates in row 2
    Attached Files Attached Files
    Last edited by JohnTopley; 12-21-2023 at 05:11 PM.

  9. #9
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,352

    Re: Calculations with VBA: Sum Product and Rate Lookup

    And what happens when the "new" effective date expires ????

  10. #10
    Forum Contributor
    Join Date
    11-06-2021
    Location
    Tripoli
    MS-Off Ver
    Still using 2007 in 2023
    Posts
    289

    Re: Calculations with VBA: Sum Product and Rate Lookup

    Hi John, I hope you're doing well. I apologize for the delay in responding. I've discussed your proposed effective date solution with my teammates, and they've decided to implement it. In the event that the effective date expires, the plan is to transition to another sheet. Thank you so much for your code – your solution has significantly streamlined our processes. Your assistance is greatly appreciated.

  11. #11
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,352

    Re: Calculations with VBA: Sum Product and Rate Lookup

    Thank you for the update and rep.

    It is pleasing to hear that the proposed solution meets your need (and aided your productivity).

+ 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. Monthly run rate calculations with FROM and TO dates
    By AFGP in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 06-09-2020, 10:13 AM
  2. [SOLVED] Find Out Nearest rate more or less from data for particular product
    By mangesh.mehendale in forum Excel General
    Replies: 4
    Last Post: 11-16-2018, 08:23 AM
  3. Electricity Calculations based on Peak and Off Peak Rate
    By mrwrighty in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 09-11-2014, 07:43 AM
  4. Conversion rate calculations with PowerPivots ?
    By ANS in forum Excel Charting & Pivots
    Replies: 9
    Last Post: 08-21-2013, 02:08 AM
  5. Replies: 0
    Last Post: 05-07-2013, 05:19 PM
  6. Calculations (pro-rate)
    By KLahvic in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 06-03-2009, 10:05 AM
  7. Product Master TI HI calculations/formula
    By Paul28 in forum Excel General
    Replies: 2
    Last Post: 10-22-2008, 02:40 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