+ Reply to Thread
Results 1 to 5 of 5

Painting cells whose sum is zero

  1. #1
    Registered User
    Join Date
    03-06-2014
    Location
    São Paulo, Brasil
    MS-Off Ver
    Excel 2010
    Posts
    6

    Painting cells whose sum is zero

    I'm from Brazil and I need your help to solve a spreadsheet.

    I have the following values:



    8881.92
    -6,735.58
    -196546.73
    -10,229.00
    -6,003.60
    -69.60
    211,632.56
    -2,878.32
    -4,856.83
    -137.24
    -8,031.08



    I need to paint the cells whose sum is zero.

    Note that 8881.92 + - 6003.60 + - 2878.32 = zero
    and - 196,546.73 + 211,632.56 + - 10,229.00 + - 4856.83 = zero


    So I need formula or macro to paint those cells whose sum is zero, so:



    8881.92
    -6,735.58
    -196546.73
    -10,229.00
    -6,003.60

    -69.60
    211,632.56
    -2,878.32
    -4,856.83

    -137.24
    -8,031.08



    Spreadsheet with real data: Pintar1.xlsx


    Thanks in advance.
    Last edited by zizao; 03-06-2014 at 10:11 AM. Reason: attach file to message

  2. #2
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,864

    Re: Painting cells whose sum is zero

    Hi zizao,

    First take some time to read http://www.excelforum.com/forum-rule...rum-rules.html and attach your file properly (not as link to external server).

    As of merit - I do not think it would be possible to do this with formula.

    for limited number of values it can be done with macro, but for large datasets - this will be really very timeconsuming process.
    So let us know what is your real dataset size - what number of values would you treat this way.
    Best Regards,

    Kaper

  3. #3
    Registered User
    Join Date
    03-06-2014
    Location
    São Paulo, Brasil
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Painting cells whose sum is zero

    Hi Kaper,

    I have databases with 5 values ​​and also larger ones with 600 values​​, eg.

    I also think macros would be more useful in this case. But I have no idea where to start.

    Thanks for the reply.

  4. #4
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,864

    Re: Painting cells whose sum is zero

    So strightforward approach to code a macro is probably really useless (without extra constraints), because complexity of problem is 2^n (some 10^180 cases for 600 values ).

    And I assume, that you need exactly zero. Not close enough to zero, like +/- 1.


    As you posted a workbook, here is proposition of randomized locating of such groups based on my recent post: http://www.excelforum.com/excel-gene...ml#post3609912

    Please Login or Register  to view this content.
    But while it is reasonably efficient with small sets (as in sheet1 of example). in large dataset - it gives up

    Funny side observation - rarely it is able to spot group two "groups" together - from maths point of view - absolutely correct, because if:
    8881.92 + - 6003.60 + - 2878.32 = zero
    and - 196,546.73 + 211,632.56 + - 10,229.00 + - 4856.83 = zero
    then
    8881.92 + - 6003.60 + - 2878.32 + - 196,546.73 + 211,632.56 + - 10,229.00 + - 4856.83 = zero too.
    such result is visible in first sheet.

    Color coding of data is not cleared, so after runnimg a macro color interiors remain. (change in code clearcontents to delete if you wish).
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    03-06-2014
    Location
    São Paulo, Brasil
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Painting cells whose sum is zero

    Perfect! That's exactly what I needed.

    I believe it will be useful for me because the databases I have are are about this size.

    Thank you, Kaper

+ 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. Painting in Excel??
    By smarch001 in forum Excel General
    Replies: 6
    Last Post: 03-28-2009, 08:54 AM
  2. Painting Cells Formula
    By AFIOF719 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 10-17-2008, 02:10 PM
  3. [SOLVED] Painting Locked Cells
    By Shrikant in forum Excel General
    Replies: 3
    Last Post: 08-20-2006, 01:10 PM
  4. [SOLVED] cell painting
    By idem idem in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 04-04-2006, 06:20 PM
  5. comparing and painting cells
    By redf1re in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-10-2006, 03:32 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