{"id":137529,"date":"2024-04-28T12:54:08","date_gmt":"2024-04-28T04:54:08","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/137529.html"},"modified":"2024-04-28T12:54:12","modified_gmt":"2024-04-28T04:54:12","slug":"excel%e8%a1%a8%e6%a0%bc%e5%a6%82%e4%bd%95%e9%9a%94%e5%88%97%e6%b1%82%e5%92%8c","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/137529.html","title":{"rendered":"excel\u8868\u683c\u5982\u4f55\u9694\u5217\u6c42\u548c"},"content":{"rendered":"<p style=\"text-align:center\"><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/24133712\/a6f9582e-c27d-4f81-a361-a32971841b2a.webp\" alt=\"excel\u8868\u683c\u5982\u4f55\u9694\u5217\u6c42\u548c\" \/><\/p>\n<p><p><strong>Excel\u8868\u683c\u9694\u5217\u6c42\u548c<\/strong>\u53ef\u4ee5\u901a\u8fc7\u591a\u79cd\u65b9\u6cd5\u5b9e\u73b0\uff0c\u4f8b\u5982\u4f7f\u7528\u516c\u5f0f\u3001\u540d\u79f0\u5b9a\u4e49\u3001\u5e2e\u52a9\u5217\u6216\u4f7f\u7528VBA\u5b8f\u3002\u8fd9\u4e9b\u65b9\u6cd5\u53ef\u4ee5\u5e2e\u52a9\u7528\u6237\u5bf9\u975e\u76f8\u90bb\u5217\u4e2d\u7684\u6570\u636e\u8fdb\u884c\u6c42\u548c\u3002\u4e0b\u9762\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u51e0\u79cd\u5e38\u89c1\u7684\u5b9e\u73b0\u65b9\u5f0f\u3002<\/p>\n<\/p>\n<p><h3>\u4e00\u3001\u4f7f\u7528SUM\u51fd\u6570\u7ed3\u5408\u5f15\u7528<\/h3>\n<\/p>\n<p><p>\u6700\u76f4\u63a5\u7684\u65b9\u6cd5\u662f\u4f7f\u7528SUM\u51fd\u6570\uff0c<strong>\u76f4\u63a5\u5f15\u7528\u9700\u8981\u6c42\u548c\u7684\u5217<\/strong>\u3002\u6b64\u65b9\u6cd5\u7b80\u5355\u660e\u4e86\uff0c\u9002\u5408\u5c11\u91cf\u975e\u76f8\u90bb\u5217\u7684\u6c42\u548c\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-excel\">=SUM(A2:A100, C2:C100, E2:E100)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u4ee5\u4e0a\u516c\u5f0f\u5c06\u4f1a\u5bf9A\u3001C\u3001E\u5217\u4ece\u7b2c2\u884c\u5230\u7b2c100\u884c\u7684\u6570\u636e\u8fdb\u884c\u6c42\u548c\u3002\u6bcf\u4e2a\u5217\u8303\u56f4\u4ee5\u9017\u53f7\u9694\u5f00\u3002<\/p>\n<\/p>\n<p><h3>\u4e8c\u3001\u4f7f\u7528\u81ea\u5b9a\u4e49\u51fd\u6570<\/h3>\n<\/p>\n<p><p>\u5f53\u9700\u8981\u5bf9\u4f17\u591a\u9694\u5217\u6c42\u548c\u800c\u8fd9\u4e9b\u5217\u89c4\u5f8b\u6027\u5f3a\u65f6\uff0c\u53ef\u4ee5\u521b\u5efa\u4e00\u4e2a\u81ea\u5b9a\u4e49\u51fd\u6570\u3002<strong>\u901a\u8fc7\u540d\u79f0\u7ba1\u7406\u5668\u521b\u5efa\u590d\u5408\u516c\u5f0f<\/strong>\uff0c\u8be5\u516c\u5f0f\u53ef\u4ee5\u5e94\u7528\u4e00\u4e2a\u901a\u7528\u89c4\u5219\u6765\u5b9e\u73b0\u9694\u5217\u6c42\u548c\u3002<\/p>\n<\/p>\n<ol>\n<li>\u6253\u5f00\u540d\u79f0\u7ba1\u7406\u5668\u3002<\/li>\n<li>\u521b\u5efa\u65b0\u540d\u79f0\uff0c\u5728\u201c\u5f15\u7528\u81f3\u201d\u4e2d\u8f93\u5165\u516c\u5f0f\uff08\u5982\u9694\u4e00\u5217\u6c42\u548c\u7684\u516c\u5f0f\uff09\u3002<\/li>\n<li>\u5728\u5de5\u4f5c\u8868\u4e2d\u4f7f\u7528\u65b0\u521b\u5efa\u7684\u540d\u79f0\u4f5c\u4e3a\u51fd\u6570\u3002<\/li>\n<\/ol>\n<p><h3>\u4e09\u3001\u4f7f\u7528\u8f85\u52a9\u5217<\/h3>\n<\/p>\n<p><p>\u5f53\u9694\u5217\u89c4\u5f8b\u4e0d\u662f\u5f88\u5f3a\u6216\u9700\u8981\u52a8\u6001\u53d8\u5316\u65f6\uff0c\u53ef\u4ee5<strong>\u8bbe\u7f6e\u8f85\u52a9\u5217<\/strong>\u7528\u4ee5\u6807\u8bb0\u548c\u8ba1\u7b97\u3002\u5c06\u8981\u6c42\u548c\u7684\u5217\u6807\u8bb0\u51fa\u6765\uff0c\u7136\u540e\u901a\u8fc7IF\u51fd\u6570\u7ed3\u5408SUM\u548c\u8f85\u52a9\u5217\u8fdb\u884c\u6c42\u548c\u3002<\/p>\n<\/p>\n<ol>\n<li>\u5728\u4e00\u4e2a\u7a7a\u767d\u5217\u8f93\u5165IF\u51fd\u6570\uff0c\u5224\u65ad\u8be5\u5217\u662f\u5426\u4e3a\u9700\u8981\u6c42\u548c\u7684\u5217\u3002<\/li>\n<li>\u4f7f\u7528SUM\u51fd\u6570\u6c42\u548c\u8fd9\u4e9b\u88ab\u6807\u8bb0\u4e3a\u201c\u771f\u201d\u7684\u5217\u3002<\/li>\n<\/ol>\n<p><p>\u4f8b\u5982\uff0c\u5982\u679c\u8981\u6c42\u548c\u6240\u6709\u7f16\u53f7\u4e3a\u5947\u6570\u7684\u5217\uff0c\u53ef\u4ee5\u5728\u8f85\u52a9\u5217\u4f7f\u7528\u5982\u4e0b\u516c\u5f0f\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-excel\">=IF(MOD(COLUMN(B1),2)=1,B1,0)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u7136\u540e\uff0c\u5bf9\u8f85\u52a9\u5217\u8fdb\u884c\u6c42\u548c\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-excel\">=SUM(Z2:Z100)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u56db\u3001\u8fd0\u7528\u6570\u7ec4\u516c\u5f0f<\/h3>\n<\/p>\n<p><p>\u5982\u679c\u8981\u5904\u7406\u5927\u91cf\u6570\u636e\u5e76\u4e14\u9694\u5217\u89c4\u5f8b\u6027\u5f3a\uff0c\u53ef\u4ee5\u4f7f\u7528\u6570\u7ec4\u516c\u5f0f\u3002<strong>\u6570\u7ec4\u516c\u5f0f\u53ef\u4ee5\u4e00\u6b21\u6027\u5904\u7406\u591a\u4e2a\u8ba1\u7b97\u64cd\u4f5c<\/strong>\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-excel\">=SUM(IF(MOD(COLUMN(A1:Z1),2)=0,A2:Z100))<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u6309Ctrl+Shift+Enter\u952e\u53ef\u4ee5\u5c06\u4e0a\u8ff0\u516c\u5f0f\u8f6c\u6362\u4e3a\u6570\u7ec4\u516c\u5f0f\u5e76\u6c42\u548c\u9694\u5217\u7684\u503c\u3002<\/p>\n<\/p>\n<p><h3>\u4e94\u3001VBA\u5b8f\u7f16\u7a0b<\/h3>\n<\/p>\n<p><p>\u5bf9\u4e8e\u66f4\u590d\u6742\u7684\u6216\u8005\u662f\u52a8\u6001\u53d8\u5316\u7684\u9694\u5217\u6c42\u548c\u9700\u6c42\uff0c\u53ef\u4ee5\u91c7\u7528VBA\u5b8f\u7f16\u7a0b\u3002<strong>\u901a\u8fc7\u7f16\u5199VBA\u4ee3\u7801\u5b9e\u73b0\u9ad8\u5ea6\u81ea\u5b9a\u4e49\u7684\u6c42\u548c\u529f\u80fd<\/strong>\u3002<\/p>\n<\/p>\n<ol>\n<li>\u6253\u5f00VBA\u7f16\u8f91\u5668\uff08\u5feb\u6377\u952e\u4e3aAlt + F11\uff09\u3002<\/li>\n<li>\u7f16\u5199\u4e00\u4e2aVBA\u51fd\u6570\uff0c\u8be5\u51fd\u6570\u53ef\u4ee5\u6839\u636e\u8bbe\u5b9a\u89c4\u5219\u5bf9\u6307\u5b9a\u533a\u57df\u8fdb\u884c\u9694\u5217\u6c42\u548c\u3002<\/li>\n<li>\u5728Excel\u5de5\u4f5c\u8868\u4e2d\u8c03\u7528\u8be5VBA\u51fd\u6570\u3002<\/li>\n<\/ol>\n<p><p>\u4f8b\u5982\uff0c\u4ee5\u4e0b\u662f\u4e00\u4e2a\u7b80\u5355\u7684VBA\u51fd\u6570\uff0c\u5b9e\u73b0\u4e86\u5bf9\u56fa\u5b9a\u884c\u3001\u9694\u5217\u6c42\u548c\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-vba\">Function AlternateSum(rng As Range) As Double<\/p>\n<p>    Dim cell As Range<\/p>\n<p>    Dim SumResult As Double<\/p>\n<p>    For Each cell In rng.Cells<\/p>\n<p>        If cell.Column Mod 2 = 0 Then &#039;\u5047\u8bbe\u6211\u4eec\u53ea\u6c42\u5076\u6570\u5217\u7684\u548c<\/p>\n<p>            SumResult = SumResult + cell.Value<\/p>\n<p>        End If<\/p>\n<p>    Next cell<\/p>\n<p>    AlternateSum = SumResult<\/p>\n<p>End Function<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728Excel\u5355\u5143\u683c\u4e2d\u8c03\u7528\u8fd9\u4e2a\u51fd\u6570\u5982\u4e0b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-excel\">=AlternateSum(A1:Z1)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u603b\u7ed3\u591a\u4e2a\u65b9\u6cd5\uff0c\u7528\u6237\u53ef\u4ee5\u6839\u636e\u81ea\u5df1\u7684\u9700\u6c42\u548c\u9694\u5217\u6c42\u548c\u7684\u590d\u6742\u7a0b\u5ea6\u9009\u62e9\u6700\u5408\u9002\u7684\u65b9\u5f0f\u3002\u5bf9\u4e8e\u5e38\u89c4\u64cd\u4f5c\uff0c\u76f4\u63a5\u4f7f\u7528SUM\u51fd\u6570\u7ed3\u5408\u5f15\u7528\u975e\u5e38\u4fbf\u6377\uff1b\u800c\u5f53\u9762\u5bf9\u5927\u91cf\u4e14\u89c4\u5f8b\u6027\u9694\u5217\u6570\u636e\u65f6\uff0cVBA\u5219\u63d0\u4f9b\u4e86\u66f4\u5927\u7684\u7075\u6d3b\u6027\u3002\u9002\u5f53\u4f7f\u7528\u8f85\u52a9\u5217\u4e0e\u6570\u7ec4\u516c\u5f0f\u4e5f\u53ef\u4ee5\u9ad8\u6548\u89e3\u51b3\u95ee\u9898\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p><strong>\u5982\u4f55\u5728Excel\u8868\u683c\u4e2d\u8fdb\u884c\u5217\u6c42\u548c\uff1f<\/strong><\/p>\n<p>\u5728Excel\u8868\u683c\u4e2d\uff0c\u53ef\u4ee5\u901a\u8fc7\u4f7f\u7528SUM\u51fd\u6570\u6765\u8fdb\u884c\u5217\u6c42\u548c\u3002\u5177\u4f53\u64cd\u4f5c\u5982\u4e0b\uff1a<\/p>\n<ol>\n<li>\u5728\u9700\u8981\u6c42\u548c\u7684\u5217\u4e0a\u65b9\u7684\u7a7a\u767d\u5355\u5143\u683c\u4e2d\u8f93\u5165SUM\u51fd\u6570\uff0c\u5982<code>=SUM(A1:A10)<\/code>\u3002<\/li>\n<li>A1:A10\u4e3a\u9700\u8981\u8fdb\u884c\u6c42\u548c\u7684\u5355\u5143\u683c\u8303\u56f4\u3002\u53ef\u4ee5\u6839\u636e\u5b9e\u9645\u60c5\u51b5\u8fdb\u884c\u8c03\u6574\u3002<\/li>\n<li>\u6309\u4e0bEnter\u952e\u5b8c\u6210\u6c42\u548c\u64cd\u4f5c\uff0c\u4f1a\u5728\u8be5\u5355\u5143\u683c\u4e2d\u663e\u793a\u6c42\u548c\u7ed3\u679c\u3002<\/li>\n<\/ol>\n<p><strong>\u5982\u4f55\u5728Excel\u8868\u683c\u4e2d\u9694\u5217\u8fdb\u884c\u6c42\u548c\uff1f<\/strong><\/p>\n<p>\u5982\u679c\u9700\u8981\u5728Excel\u8868\u683c\u4e2d\u9694\u5217\u8fdb\u884c\u6c42\u548c\uff0c\u53ef\u4ee5\u901a\u8fc7\u4f7f\u7528SUM\u51fd\u6570\u7684\u53c2\u6570\u8c03\u6574\u6765\u5b9e\u73b0\u3002\u5177\u4f53\u64cd\u4f5c\u5982\u4e0b\uff1a<\/p>\n<ol>\n<li>\u5728\u9700\u8981\u6c42\u548c\u7684\u7b2c\u4e00\u4e2a\u5355\u5143\u683c\u4e0a\u65b9\u7684\u7a7a\u767d\u5355\u5143\u683c\u4e2d\u8f93\u5165SUM\u51fd\u6570\uff0c\u5982<code>=SUM(A1,C1,E1,G1,I1)<\/code>\u3002<\/li>\n<li>A1,C1,E1,G1,I1\u5373\u4e3a\u9700\u8981\u8fdb\u884c\u6c42\u548c\u7684\u5355\u5143\u683c\u3002\u4f7f\u7528\u9017\u53f7\u5c06\u8fd9\u4e9b\u5355\u5143\u683c\u9694\u5f00\uff0c\u5373\u53ef\u5b9e\u73b0\u9694\u5217\u6c42\u548c\u3002<\/li>\n<li>\u6309\u4e0bEnter\u952e\u5b8c\u6210\u6c42\u548c\u64cd\u4f5c\uff0c\u4f1a\u5728\u8be5\u5355\u5143\u683c\u4e2d\u663e\u793a\u6c42\u548c\u7ed3\u679c\u3002<\/li>\n<\/ol>\n<p><strong>\u5982\u4f55\u5728Excel\u8868\u683c\u4e2d\u5206\u6bb5\u9694\u5217\u8fdb\u884c\u6c42\u548c\uff1f<\/strong><\/p>\n<p>\u82e5\u9700\u8981\u5728Excel\u8868\u683c\u4e2d\u8fdb\u884c\u5206\u6bb5\u9694\u5217\u6c42\u548c\uff0c\u53ef\u4ee5\u901a\u8fc7\u4f7f\u7528SUM\u51fd\u6570\u4e0e\u5192\u53f7\u7b26\u53f7\u6765\u5b9e\u73b0\u3002\u5177\u4f53\u64cd\u4f5c\u5982\u4e0b\uff1a<\/p>\n<ol>\n<li>\u5728\u9700\u8981\u8fdb\u884c\u6c42\u548c\u7684\u7b2c\u4e00\u4e2a\u5355\u5143\u683c\u4e0a\u65b9\u7684\u7a7a\u767d\u5355\u5143\u683c\u4e2d\u8f93\u5165SUM\u51fd\u6570\uff0c\u5982<code>=SUM(A1:D1,F1:I1,K1:M1)<\/code>\u3002<\/li>\n<li>A1:D1,F1:I1,K1:M1\u5373\u4e3a\u9700\u8981\u8fdb\u884c\u6c42\u548c\u7684\u5355\u5143\u683c\u8303\u56f4\u3002\u4f7f\u7528\u5192\u53f7\u7b26\u53f7\u5c06\u6bcf\u4e2a\u5206\u6bb5\u7684\u8d77\u59cb\u5355\u5143\u683c\u548c\u7ed3\u675f\u5355\u5143\u683c\u8fde\u63a5\uff0c\u5373\u53ef\u5b9e\u73b0\u5206\u6bb5\u9694\u5217\u6c42\u548c\u3002<\/li>\n<li>\u6309\u4e0bEnter\u952e\u5b8c\u6210\u6c42\u548c\u64cd\u4f5c\uff0c\u4f1a\u5728\u8be5\u5355\u5143\u683c\u4e2d\u663e\u793a\u6c42\u548c\u7ed3\u679c\u3002<\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"Excel\u8868\u683c\u9694\u5217\u6c42\u548c\u53ef\u4ee5\u901a\u8fc7\u591a\u79cd\u65b9\u6cd5\u5b9e\u73b0\uff0c\u4f8b\u5982\u4f7f\u7528\u516c\u5f0f\u3001\u540d\u79f0\u5b9a\u4e49\u3001\u5e2e\u52a9\u5217\u6216\u4f7f\u7528VBA\u5b8f\u3002\u8fd9\u4e9b\u65b9\u6cd5\u53ef\u4ee5\u5e2e\u52a9\u7528\u6237 [&hellip;]","protected":false},"author":3,"featured_media":137534,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[37],"tags":[],"acf":[],"_links":{"self":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/137529"}],"collection":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/comments?post=137529"}],"version-history":[{"count":0,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/137529\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/137534"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=137529"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=137529"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=137529"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}