{"id":1037,"date":"2019-10-12T17:38:40","date_gmt":"2019-10-12T09:38:40","guid":{"rendered":"http:\/\/www.fyndpro.com\/?p=1037"},"modified":"2026-08-27T16:15:28","modified_gmt":"2026-08-27T08:15:28","slug":"sumif-by-color","status":"publish","type":"post","link":"https:\/\/www.fyndpro.com\/en\/sumif-by-color\/","title":{"rendered":"Sum by cell color with SUMIF"},"content":{"rendered":"<p class=\"wp-block-paragraph\">In Excel, the SUMIF function is typically used to sum numbers based on specific conditions that target cell contents. However, many users ask whether it's possible to sum based on a cell's fill color.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Can SUMIF sum by cell color?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">In fact, SUMIF cannot directly sum by cell fill color. However, we can use a method to convert the fill color into a number, thereby enabling summation by color.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How to convert cell fill color to a number?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">We can use Excel's macro sheet functions (also called 0 functions) in <strong>GET.CELL<\/strong> function to convert the fill color into a number. Macro sheet functions were introduced in Excel version 4; although they cannot be used directly in cells in current versions, they can still be called via defined names.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Macro sheet functions \u2014 capabilities<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Macro sheet functions, also called 0 functions, are from Excel version 4; for compatibility, current versions can still call them.<\/li>\n\n\n\n<li>Macro sheet functions can do things that current functions or tricks cannot, such as retrieving a cell's fill color value or getting a list of worksheet names.<\/li>\n\n\n\n<li>Macro sheet functions cannot be used directly in cells; you must first define a name and then use that name in a cell.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Solution steps<\/h2>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Define a name<\/strong>\uff1a<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>In Excel, select 'Name Manager' from the Formulas menu.<\/li>\n\n\n\n<li>Enter a custom name in the 'Name' field, for example <code>color<\/code>\u3002<\/li>\n\n\n\n<li>Enter the formula in the 'Refers to' field:<code>=GET.CELL(63, \u5de5\u4f5c\u88681!$B2)&amp;T(NOW())<\/code>. This returns the fill color index of the specified cell.<\/li>\n<\/ul>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li><strong>Use the name to get the fill color index<\/strong>\uff1a<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>In cell C2 enter <code>=color<\/code>, which will retrieve the fill color index for that cell.<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"693\" height=\"429\" src=\"https:\/\/i0.wp.com\/www.fyndpro.com\/wp-content\/uploads\/2019\/10\/SUMIF%E6%8C%89%E5%84%B2%E5%AD%98%E6%A0%BC%E5%BA%95%E8%89%B2%E5%8A%A0%E7%B8%BD-2.png?resize=693%2C429\" alt=\"\" class=\"wp-image-1041\" srcset=\"https:\/\/i0.wp.com\/www.fyndpro.com\/wp-content\/uploads\/2019\/10\/SUMIF%E6%8C%89%E5%84%B2%E5%AD%98%E6%A0%BC%E5%BA%95%E8%89%B2%E5%8A%A0%E7%B8%BD-2.png?w=693&amp;ssl=1 693w, https:\/\/i0.wp.com\/www.fyndpro.com\/wp-content\/uploads\/2019\/10\/SUMIF%E6%8C%89%E5%84%B2%E5%AD%98%E6%A0%BC%E5%BA%95%E8%89%B2%E5%8A%A0%E7%B8%BD-2.png?resize=150%2C93&amp;ssl=1 150w, https:\/\/i0.wp.com\/www.fyndpro.com\/wp-content\/uploads\/2019\/10\/SUMIF%E6%8C%89%E5%84%B2%E5%AD%98%E6%A0%BC%E5%BA%95%E8%89%B2%E5%8A%A0%E7%B8%BD-2.png?resize=300%2C186&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.fyndpro.com\/wp-content\/uploads\/2019\/10\/SUMIF%E6%8C%89%E5%84%B2%E5%AD%98%E6%A0%BC%E5%BA%95%E8%89%B2%E5%8A%A0%E7%B8%BD-2.png?resize=230%2C142&amp;ssl=1 230w, https:\/\/i0.wp.com\/www.fyndpro.com\/wp-content\/uploads\/2019\/10\/SUMIF%E6%8C%89%E5%84%B2%E5%AD%98%E6%A0%BC%E5%BA%95%E8%89%B2%E5%8A%A0%E7%B8%BD-2.png?resize=350%2C217&amp;ssl=1 350w, https:\/\/i0.wp.com\/www.fyndpro.com\/wp-content\/uploads\/2019\/10\/SUMIF%E6%8C%89%E5%84%B2%E5%AD%98%E6%A0%BC%E5%BA%95%E8%89%B2%E5%8A%A0%E7%B8%BD-2.png?resize=480%2C297&amp;ssl=1 480w\" sizes=\"auto, (max-width: 693px) 100vw, 693px\" \/><\/figure>\n\n\n\n<ol start=\"3\" class=\"wp-block-list\">\n<li><strong>Summing by fill color<\/strong>\uff1a<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>In cell D2 enter <code>=SUMIF(C2:C12, C2, B2:B12)<\/code>, so you can sum based on the fill color index.<\/li>\n<\/ul>\n\n\n\n<ol start=\"4\" class=\"wp-block-list\">\n<li><strong>Refresh fill color changes<\/strong>\uff1a<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>If any cell's fill color changes, press F9 to recalculate.<\/li>\n<\/ul>\n\n\n\n<ul class=\"wp-block-list\">\n<li><\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"779\" height=\"475\" src=\"https:\/\/i0.wp.com\/www.fyndpro.com\/wp-content\/uploads\/2019\/10\/SUMIF%E6%8C%89%E5%84%B2%E5%AD%98%E6%A0%BC%E5%BA%95%E8%89%B2%E5%8A%A0%E7%B8%BD2.png?resize=779%2C475\" alt=\"\" class=\"wp-image-1042\" srcset=\"https:\/\/i0.wp.com\/www.fyndpro.com\/wp-content\/uploads\/2019\/10\/SUMIF%E6%8C%89%E5%84%B2%E5%AD%98%E6%A0%BC%E5%BA%95%E8%89%B2%E5%8A%A0%E7%B8%BD2.png?w=779&amp;ssl=1 779w, https:\/\/i0.wp.com\/www.fyndpro.com\/wp-content\/uploads\/2019\/10\/SUMIF%E6%8C%89%E5%84%B2%E5%AD%98%E6%A0%BC%E5%BA%95%E8%89%B2%E5%8A%A0%E7%B8%BD2.png?resize=150%2C91&amp;ssl=1 150w, https:\/\/i0.wp.com\/www.fyndpro.com\/wp-content\/uploads\/2019\/10\/SUMIF%E6%8C%89%E5%84%B2%E5%AD%98%E6%A0%BC%E5%BA%95%E8%89%B2%E5%8A%A0%E7%B8%BD2.png?resize=300%2C183&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.fyndpro.com\/wp-content\/uploads\/2019\/10\/SUMIF%E6%8C%89%E5%84%B2%E5%AD%98%E6%A0%BC%E5%BA%95%E8%89%B2%E5%8A%A0%E7%B8%BD2.png?resize=768%2C468&amp;ssl=1 768w, https:\/\/i0.wp.com\/www.fyndpro.com\/wp-content\/uploads\/2019\/10\/SUMIF%E6%8C%89%E5%84%B2%E5%AD%98%E6%A0%BC%E5%BA%95%E8%89%B2%E5%8A%A0%E7%B8%BD2.png?resize=230%2C140&amp;ssl=1 230w, https:\/\/i0.wp.com\/www.fyndpro.com\/wp-content\/uploads\/2019\/10\/SUMIF%E6%8C%89%E5%84%B2%E5%AD%98%E6%A0%BC%E5%BA%95%E8%89%B2%E5%8A%A0%E7%B8%BD2.png?resize=350%2C213&amp;ssl=1 350w, https:\/\/i0.wp.com\/www.fyndpro.com\/wp-content\/uploads\/2019\/10\/SUMIF%E6%8C%89%E5%84%B2%E5%AD%98%E6%A0%BC%E5%BA%95%E8%89%B2%E5%8A%A0%E7%B8%BD2.png?resize=480%2C293&amp;ssl=1 480w\" sizes=\"auto, (max-width: 779px) 100vw, 779px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">By following the steps above, even though Excel's SUMIF cannot sum by fill color directly, we can use macro sheet functions to convert fill color to numbers and thus sum by color. This provides more flexibility for data analysis, especially when managing data visually by color.<\/p>\n\n\n\n<div style=\"height:var(--wp--preset--spacing--superbspacing-small)\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<div class=\"wp-block-group alignfull has-mono-3-background-color has-background is-nowrap is-layout-flex wp-container-core-group-is-layout-16e08174 wp-block-group-is-layout-flex\" style=\"margin-top:0;margin-bottom:0;padding-top:var(--wp--preset--spacing--superbspacing-large);padding-right:var(--wp--preset--spacing--superbspacing-small);padding-bottom:var(--wp--preset--spacing--superbspacing-large);padding-left:var(--wp--preset--spacing--superbspacing-small)\">\n<h2 class=\"wp-block-heading\">Microsoft official documentation<\/h2>\n\n\n\n<div class=\"wp-block-buttons is-layout-flex wp-block-buttons-is-layout-flex\">\n<div class=\"wp-block-button\"><a class=\"wp-block-button__link wp-element-button\" href=\"https:\/\/support.microsoft.com\/zh-hk\/office\/sumif-%E5%87%BD%E6%95%B8-169b8c99-c05c-4483-a712-1697a653039b\" target=\"_blank\" rel=\"noreferrer noopener\">SUMIF<\/a><\/div>\n<\/div>\n<\/div>","protected":false},"excerpt":{"rendered":"<p>\u5728 Excel \u4e2d\uff0cSUMIF \u51fd\u6578\u901a\u5e38\u7528\u65bc\u6839\u64da\u7279\u5b9a\u689d\u4ef6\u5c0d\u6578\u5b57\u9032\u884c\u52a0\u7e3d\uff0c\u9019\u4e9b\u689d\u4ef6\u4e3b\u8981\u91dd\u5c0d\u5132\u5b58\u683c\u4e2d\u7684\u5167\u5bb9\u3002\u7136\u800c\uff0c [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":3783,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_post_was_ever_published":false},"categories":[20,8],"tags":[114,139,14,277],"class_list":["post-1037","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-onlinesupport","category-excel","tag-f9","tag-get-cell","tag-sumif","tag-data-analysis"],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"https:\/\/i0.wp.com\/www.fyndpro.com\/wp-content\/uploads\/2026\/08\/new_covers_batch_01_excel_data_validation.jpg?fit=816%2C1088&ssl=1","_links":{"self":[{"href":"https:\/\/www.fyndpro.com\/en\/wp-json\/wp\/v2\/posts\/1037","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.fyndpro.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.fyndpro.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.fyndpro.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.fyndpro.com\/en\/wp-json\/wp\/v2\/comments?post=1037"}],"version-history":[{"count":4,"href":"https:\/\/www.fyndpro.com\/en\/wp-json\/wp\/v2\/posts\/1037\/revisions"}],"predecessor-version":[{"id":3286,"href":"https:\/\/www.fyndpro.com\/en\/wp-json\/wp\/v2\/posts\/1037\/revisions\/3286"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.fyndpro.com\/en\/wp-json\/wp\/v2\/media\/3783"}],"wp:attachment":[{"href":"https:\/\/www.fyndpro.com\/en\/wp-json\/wp\/v2\/media?parent=1037"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.fyndpro.com\/en\/wp-json\/wp\/v2\/categories?post=1037"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.fyndpro.com\/en\/wp-json\/wp\/v2\/tags?post=1037"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}