+ Reply to Thread
Results 1 to 2 of 2

Matching sum values of two arrays in VBA

  1. #1
    Registered User
    Join Date
    01-14-2020
    Location
    Singapore
    MS-Off Ver
    365
    Posts
    2

    Post Matching sum values of two arrays in VBA

    I have to match both columns below. To get a match you need to sum/combine some values in TC column and combine some values in AE column. (Per sample table below - e.g-1 sum of Items 1 & 2 of TC Column (20,378) will match to the sum of items 2 & 3 of AE Column (20,378) e.-2 sum of items 15,18,19 of TC Column will match to the sum of items 12, 14, 15, 16, 20 of AE column). No single amount to sum values matching. To get a match you always need to sum values in both columns.

    In my original code, these columns are stored in two different arrays. So I have to perform the loop matching inside these arrays. Hence, the reason why my code begins with storing the values in two arrays below.

    This is what I want to achieve in my loop:

    IF TCval 1 + TCval 3 = AEval1 + AEval2 + AEvall3 etc.. Then
    Color the matched cells and set the values to 0 in both arrays then re-perform the loop again.


    zKbOs.png



    This what I have so far. Nested loop. Just finished 2 TC vs 2AE, 3AE etc... i need to compare up til 5 TC. Im sure there is a better way to do this or may be a better way to code my loops.

    Please Login or Register  to view this content.

  2. #2
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: Matching sum values of two arrays in VBA

    To help to help you, can you attach an Excel sample file showing what you want to achieve
    Last edited by PCI; 01-14-2020 at 05:14 PM.
    - Battle without fear gives no glory - Just try

+ 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. vba compare arrays and remove exact matching arrays
    By jacojvv in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 10-25-2013, 07:30 AM
  2. Arrays Index Matching Macro Help
    By o2FearX in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-18-2013, 03:56 PM
  3. [SOLVED] Matching Arrays Macro Code Almost Right
    By boldcode in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 05-23-2013, 08:14 AM
  4. [SOLVED] How to find all unique, matching values betwen two arrays of cells
    By exmonkey in forum Excel General
    Replies: 11
    Last Post: 06-20-2012, 05:47 PM
  5. Matching value in two arrays
    By wondering2 in forum Excel General
    Replies: 2
    Last Post: 12-26-2010, 09:58 PM
  6. Matching two arrays - Part 1
    By PradeepRed in forum Excel General
    Replies: 2
    Last Post: 09-17-2010, 04:16 AM
  7. [SOLVED] Arrays - declaration, adding values to arrays and calculation
    By Maxi in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-17-2006, 11:15 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