+ Reply to Thread
Results 1 to 23 of 23

VBA Vlookup with calculation - no duplicates

  1. #1
    Registered User
    Join Date
    01-01-2005
    Posts
    56

    VBA Vlookup with calculation - no duplicates

    Hi,

    I have a sheet that I am trying to get some metrics on and need to do them with VBA. Basically, I need to get the SUM of all "Ratings" where the status is "On" and exclude any duplicate "Number" (including the rating only once per that "number") . I'll also need the total amount of rows that got calculated (for the next calculation)

    After it has the SUM and number of rows:

    I want it to SUM up the "rating" for the "number of rows" calculated in the above calculation (excluding duplicates).

    Further explanation is in the sheet provided.

    Thanks
    Attached Files Attached Files

  2. #2
    Registered User
    Join Date
    01-01-2005
    Posts
    56

    Re: VBA Vlookup with calculation - no duplicates

    Bump - Anyone?

  3. #3
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: VBA Vlookup with calculation - no duplicates

    Hi Cboggie

    In all instances except one you've highlighted the first occurrence of duplicate items. The exception is 117.75...any reason?
    John

    If you have issues with Code I've provided, I appreciate your feedback.

    In the event Code provided resolves your issue, please mark your Thread as SOLVED.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

  4. #4
    Registered User
    Join Date
    01-01-2005
    Posts
    56

    Re: VBA Vlookup with calculation - no duplicates

    Quote Originally Posted by jaslake View Post
    Hi Cboggie

    In all instances except one you've highlighted the first occurrence of duplicate items. The exception is 117.75...any reason?
    Nope, as long as it includes one, its good

  5. #5
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: VBA Vlookup with calculation - no duplicates

    Hi Cboggie

    This Code is in the attached...please see my Notes in the File...click the Button to fire the Code
    Please Login or Register  to view this content.
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    01-01-2005
    Posts
    56

    Re: VBA Vlookup with calculation - no duplicates

    Yes!

    That works perfect. Thanks jaslake.

  7. #7
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: VBA Vlookup with calculation - no duplicates

    You're welcome...glad I could help. Thanks for the Rep.

  8. #8
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: VBA Vlookup with calculation - no duplicates

    You're welcome...glad I could help.

    If this resolves your issue please mark your Thread as SOLVED.

    New quick method:
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

    Or you can use this way:
    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save

  9. #9
    Registered User
    Join Date
    01-01-2005
    Posts
    56

    Re: VBA Vlookup with calculation - no duplicates

    After trying to integrate it into my current sheet, I'm having all kinds of problems. Here is a new sheet that may help me integrate it more into the bigger one.

    Same principle with a few changes.
    • I'll need to copy it to other sheets (possibly use Active.sheet?)
    • I may need to add up to 8 status' to include/exclude

    Thanks!
    Attached Files Attached Files

  10. #10
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: VBA Vlookup with calculation - no duplicates

    Hi Cboggie

    In the original File we were excluding duplicate Index Numbers in the first calculation...in this File you have indicated this
    Same as last time, exclude duplicate "Number" while calculating the "Index" SUM for everything else that has a status of (On or Inprg).
    Which is it Duplicate Index Numbers or Duplicate Numbers??

    I don't understand this...run through it step by step...you want the calculation placed in Cell J27 of a new Sheet and then delete that new Sheet??

    For the pasting , I think it would be better if it would create a new sheet then delete it after the calculation is finished. Putting the results in J27.
    What are all these possible combinations
    Status' to include/exclude will change and possibly have 2-8 different ones that I'll need to change

  11. #11
    Registered User
    Join Date
    01-01-2005
    Posts
    56

    Re: VBA Vlookup with calculation - no duplicates

    Excluding "Numbers"

    J27 of the same sheet. The sheet that we copy/paste to, can be deleted.

    With the all the status', i may need to change them...thats all. Just thought is was worth mentioning.

    thanks

  12. #12
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: VBA Vlookup with calculation - no duplicates

    Hi Cboggie

    Either we're not communicating or this is a change
    Excluding "Numbers"
    In the Original File, for the First Calculation, we were eliminating Duplicate Index Numbers (Column A). In the Second Calculation we were eliminating Duplicate Numbers (Column C).

    If this IS a change...show me your expected output and how you arrived at it.

    Regarding this...what are they...ALL of them....don't care to rewrite the Code yet again...
    With the all the status', i may need to change them

  13. #13
    Registered User
    Join Date
    01-01-2005
    Posts
    56

    Re: VBA Vlookup with calculation - no duplicates

    Quote Originally Posted by jaslake View Post
    Hi Cboggie

    Either we're not communicating or this is a change
    In the Original File, for the First Calculation, we were eliminating Duplicate Index Numbers (Column A). In the Second Calculation we were eliminating Duplicate Numbers (Column C).

    Yes, you are right. I changed it to look at duplicate "numbers". We are only worried about duplicate "numbers", not duplicate "index". Duplicate "indexes" are ok, as long as they don't have the same "number"


    Quote Originally Posted by jaslake View Post
    If this IS a change...show me your expected output and how you arrived at it.

    Let me know if that makes sense, or i need more clarification

    Regarding this...what are they...ALL of them....don't care to rewrite the Code yet again...
    The status' may change, i just thought it was worth mentioning that I would need to be able to change the status'.

  14. #14
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: VBA Vlookup with calculation - no duplicates

    Hi Cboggie

    I need to see it...what do you have...what do you want it to be...show me the input...show me your expected output and how you arrived at it.

    Only you can define this...if you can't, it can't be done (not by me).

  15. #15
    Registered User
    Join Date
    01-01-2005
    Posts
    56

    Re: VBA Vlookup with calculation - no duplicates

    Ok, I updated the sheet with better explanations.

    Hope that helps.vlookup3.xlsm

  16. #16
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: VBA Vlookup with calculation - no duplicates

    Hi Cboggie

    Post a worksheet that looks like this...I'll not build the Sample Data
    The data for this calculation will be pasted in from another sheet
    The data will always start on A29, so if the calculation could start there
    it would be helpful.

  17. #17
    Registered User
    Join Date
    01-01-2005
    Posts
    56

    Re: VBA Vlookup with calculation - no duplicates

    jaslake,

    appreciate your help very much. Hopefully I've got it right this time.

    Here is the sheet
    Attached Files Attached Files

  18. #18
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: VBA Vlookup with calculation - no duplicates

    Hi Cboggie

    I'll look at this tomorrow...late here.

  19. #19
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: VBA Vlookup with calculation - no duplicates

    Hi Cboggie

    Based on your Sample File what totals do you come up with?

    For the first calculation I get 1439.76 with a count of 21...for the second I get 1364.88 (for the first 21 records with no duplicates, the count is 20)...what say you?

  20. #20
    Registered User
    Join Date
    01-01-2005
    Posts
    56

    Re: VBA Vlookup with calculation - no duplicates

    Quote Originally Posted by jaslake View Post
    Hi Cboggie

    Based on your Sample File what totals do you come up with?

    For the first calculation I get 1439.76 with a count of 21...for the second I get 1364.88 (for the first 21 records with no duplicates, the count is 20)...what say you?
    I get 1439.76 > 21 rows for the first calculation

    I got 1433.58 > 21 rows for the second

    I updated with text and markups of how i got it.
    Attached Files Attached Files

  21. #21
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: VBA Vlookup with calculation - no duplicates

    Hi Cboggie

    Try the Code in the attached...
    Attached Files Attached Files

  22. #22
    Registered User
    Join Date
    01-01-2005
    Posts
    56

    Re: VBA Vlookup with calculation - no duplicates

    Yessir!!! That'll do!
    Gonna integrate it into the bigger sheet and get back with ya.

  23. #23
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: VBA Vlookup with calculation - no duplicates

    Hi Cboggie

    You're welcome...glad I could help. Thanks for the Rep.

    If this resolves your issue please mark your Thread as SOLVED.

    New quick method:
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

    Or you can use this way:
    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save

+ 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. VLOOKUP for duplicates
    By mattdh12 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 11-29-2013, 09:14 AM
  2. Vlookup With Duplicates
    By skate1991 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 04-11-2013, 08:01 AM
  3. [SOLVED] vlookup duplicates
    By par0016 in forum Excel General
    Replies: 5
    Last Post: 06-08-2012, 09:51 AM
  4. Vlookup with duplicates
    By MattP299 in forum Excel General
    Replies: 1
    Last Post: 12-19-2011, 05:22 PM
  5. Vlookup with duplicates
    By jorgetb in forum Excel - New Users/Basics
    Replies: 5
    Last Post: 07-12-2010, 05:45 AM

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