+ Reply to Thread
Results 1 to 9 of 9

Add cells based on background colour - Glitch

  1. #1
    Registered User
    Join Date
    11-27-2013
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    10

    Add cells based on background colour - Glitch

    Hi All,

    I recently created a macro (with a little help from some forums) that was designed to sum a row of cells IF the cell formatting used a particular colour in the background. It worked a treat, and this is what it looked like

    Please Login or Register  to view this content.

    It does what I want it to do, except when I use 'undo'. For instance, I change one of the cells to my special background colour (blue) - the sum changes as planned, but then if I click undo, the background changes back to the old colour (grey) but instead of the sum changing again, it keeps the new total. i.e the sum of blue cells and one grey cell. I want it to only show me the totals of my blue cells.

    Can anyone suggest how I ought to tweak the above code so that it will always show the correct total?
    Last edited by elliem19; 06-07-2016 at 12:45 AM. Reason: To comply with Rule 3

  2. #2
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: Add cells based on background colour - Glitch

    Post withdrawn
    Last edited by humdingaling; 06-07-2016 at 01:31 AM. Reason: Op Complied
    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

  3. #3
    Registered User
    Join Date
    11-27-2013
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: Add cells based on background colour - Glitch

    Thanks! Have just edited original post.

  4. #4
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: Add cells based on background colour - Glitch

    you will find the issue with UDF is it doesnt react to changes made to your spreadsheet without "re-running" the code
    i assume you know you can update by going into the cell with the formula press f2 and enter which is why you want something more "dynamic"

    Please Login or Register  to view this content.
    adding in application.volatile will somewhat remedy this but be warned, it does degrade performance due to the constant running of the code..this becomes important if the size of your spreadsheet is large or the number of times you use this UDF

    if its only something small or you dont use this UDF often you probably wont notice

    ps even with this, you need to force update (F9) in order to update formula

  5. #5
    Registered User
    Join Date
    11-27-2013
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: Add cells based on background colour - Glitch

    Fantastic, works a treat. Yet to see any major slow-down in performance, so thank you very much for your solution and explanation.

  6. #6
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: Add cells based on background colour - Glitch

    not a problem
    glad to help

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks.

  7. #7
    Registered User
    Join Date
    11-27-2013
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: Add cells based on background colour - Glitch

    One last issue has cropped up - the numbers that are pulling through are rounded to the nearest whole number. Is there any way you can suggest tweaking the VBA code so that the SUM adds to several decimal points?
    Thanks again for your help, I really appreciate it.

  8. #8
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: Add cells based on background colour - Glitch

    try using double instead of long

  9. #9
    Registered User
    Join Date
    11-27-2013
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    10

    Thumbs up Re: Add cells based on background colour - Glitch

    Perfect solution, as usual.
    Thanks again!

+ 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. [SOLVED] Search cells based on student name, cell background colour and return a tally for colour
    By drof_06 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 01-26-2016, 04:31 AM
  2. Returning value of cells based on another cells background colour
    By Prankster182 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-04-2015, 09:19 AM
  3. copy row from one worksheet to another based on background colour in row
    By willcmuk in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-17-2012, 08:47 AM
  4. Replies: 7
    Last Post: 07-16-2012, 05:10 PM
  5. [SOLVED] sum up cells by background colour
    By Mengo85 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-16-2012, 01:27 PM
  6. Filtering based on existing background colour
    By orga in forum Excel General
    Replies: 1
    Last Post: 07-13-2009, 07:46 AM
  7. IF formula based on background cell colour
    By mr_teacher in forum Excel General
    Replies: 1
    Last Post: 11-28-2007, 10:44 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