{"id":5406,"date":"2024-12-16T02:20:33","date_gmt":"2024-12-16T02:20:33","guid":{"rendered":"https:\/\/blog.ezworkapp.com\/index.php\/2024\/12\/16\/ham-tinh-tong-theo-hang-hoac-cot-bat-ky-trong-mang\/"},"modified":"2024-12-16T02:20:33","modified_gmt":"2024-12-16T02:20:33","slug":"ham-tinh-tong-theo-hang-hoac-cot-bat-ky-trong-mang","status":"publish","type":"post","link":"https:\/\/blog.ezworkapp.com\/index.php\/2024\/12\/16\/ham-tinh-tong-theo-hang-hoac-cot-bat-ky-trong-mang\/","title":{"rendered":"H\u00e0m t\u00ednh t\u1ed5ng theo h\u00e0ng ho\u1eb7c c\u1ed9t b\u1ea5t k\u1ef3 trong m\u1ea3ng"},"content":{"rendered":"<div class=\"uk-panel uk-margin\" id=\"template-dQf5b79p#1\">\n<p>\u0110\u00f4i khi l\u00e0m vi\u1ec7c v\u1edbi m\u1ea3ng, ch\u00fang ta mu\u1ed1n t\u00ednh to\u00e1n theo nh\u1eefng c\u1ed9t \/ h\u00e0ng ri\u00eang l\u1ebb trong m\u1ea3ng\u00a0\u0111\u00f3, nh\u01b0ng kh\u00f4ng c\u00f3 h\u00e0m\u00a0excel n\u00e0o c\u00f3 s\u1eb5n gi\u00fap ch\u00fang ta l\u00e0m\u00a0\u0111\u01b0\u1ee3c vi\u1ec7c n\u00e0y.\u00a0\u0110i\u1ec1u n\u00e0y\u00a0\u1ea3nh h\u01b0\u1edfng kh\u00f4ng nh\u1ecf t\u1edbi c\u00f4ng vi\u1ec7c khi ch\u00fang ta ph\u1ea3i loay hoay t\u00ecm gi\u1ea3i ph\u00e1p thay th\u1ebf, ph\u1ea3i\u00a0\u0111i\u00a0\u0111\u01b0\u1eddng v\u00f2ng. V\u1eady b\u1ea1n c\u00f3 bao gi\u1edd ngh\u0129 c\u00f3 th\u1ec3 t\u1ef1 t\u1ea1o ra 1 h\u00e0m gi\u00fap gi\u1ea3i quy\u1ebft tr\u1ef1c ti\u1ebfp c\u00f4ng vi\u1ec7c n\u00e0y? Sau\u00a0\u0111\u00e2y ch\u00fang ta c\u00f9ng xem H\u1ecdc\u00a0Excel Online l\u00e0m\u00a0\u0111i\u1ec1u\u00a0n\u00e0y\u00a0nh\u01b0 th\u1ebf n\u00e0o nh\u00e9:<\/p>\n<p>V\u00ed d\u1ee5 ch\u00fang ta c\u00f3 m\u1ea3ng d\u1eef li\u1ec7u nh\u01b0 sau:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-14453\" src=\"http:\/\/blog.ezworkapp.com\/wp-content\/uploads\/2024\/12\/heo-ham-tinh-tong-theo-mang-01.png\" width=\"374\" height=\"187\" title=\"heo-ham-tinh-tong-theo-mang-01\"><\/p>\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_61 counter-hierarchy ez-toc-counter ez-toc-transparent ez-toc-container-direction\">\n<p class=\"ez-toc-title\">Xem nhanh<\/p>\n<p><label for=\"ez-toc-cssicon-toggle-item-675f8e710c533\" class=\"ez-toc-cssicon-toggle-label\"><span class=\"\"><span class=\"eztoc-hide\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><\/span><\/span><\/label><\/p>\n<nav>\n<ul class=\"ez-toc-list ez-toc-list-level-1 \">\n<li class=\"ez-toc-page-1 ez-toc-heading-level-3\"><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/blog.hocexcel.online\/ham-tinh-tong-theo-hang-hoac-cot-bat-ky-trong-mang.html#Buoc_1_Mo_cua_so_Visual_Basic_Application_VBA\" title=\"B\u01b0\u1edbc 1: M\u1edf c\u1eeda s\u1ed5 Visual Basic Application (VBA)\">B\u01b0\u1edbc 1: M\u1edf c\u1eeda s\u1ed5 Visual Basic Application (VBA)<\/a><\/li>\n<li class=\"ez-toc-page-1 ez-toc-heading-level-3\"><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/blog.hocexcel.online\/ham-tinh-tong-theo-hang-hoac-cot-bat-ky-trong-mang.html#Buoc_2_Tao_moi_1_Module\" title=\"B\u01b0\u1edbc 2: T\u1ea1o m\u1edbi 1 Module\">B\u01b0\u1edbc 2: T\u1ea1o m\u1edbi 1 Module<\/a><\/li>\n<li class=\"ez-toc-page-1 ez-toc-heading-level-3\"><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/blog.hocexcel.online\/ham-tinh-tong-theo-hang-hoac-cot-bat-ky-trong-mang.html#Buoc_3_Tao_ham_trong_VBA_de_tinh_tong_theo_dong_bat_ky\" title=\"B\u01b0\u1edbc 3: T\u1ea1o\u00a0h\u00e0m trong VBA\u00a0\u0111\u1ec3\u00a0t\u00ednh t\u1ed5ng theo d\u00f2ng b\u1ea5t k\u1ef3\">B\u01b0\u1edbc 3: T\u1ea1o\u00a0h\u00e0m trong VBA\u00a0\u0111\u1ec3\u00a0t\u00ednh t\u1ed5ng theo d\u00f2ng b\u1ea5t k\u1ef3<\/a><\/li>\n<li class=\"ez-toc-page-1 ez-toc-heading-level-3\"><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/blog.hocexcel.online\/ham-tinh-tong-theo-hang-hoac-cot-bat-ky-trong-mang.html#Buoc_4_Cach_su_dung_ham\" title=\"B\u01b0\u1edbc 4: C\u00e1ch s\u1eed d\u1ee5ng h\u00e0m\">B\u01b0\u1edbc 4: C\u00e1ch s\u1eed d\u1ee5ng h\u00e0m<\/a><\/li>\n<\/ul>\n<\/nav>\n<\/div>\n<h3><span class=\"ez-toc-section\" id=\"Buoc_1_Mo_cua_so_Visual_Basic_Application_VBA\"><\/span>B\u01b0\u1edbc 1: M\u1edf c\u1eeda s\u1ed5 Visual Basic Application (VBA)<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>C\u00f3 2 c\u00e1ch\u00a0\u0111\u1ec3 m\u1edf c\u1eeda s\u1ed5 VBA:<\/p>\n<ul>\n<li>C\u00e1ch 1: B\u1ea5m t\u1ed5 h\u1ee3p ph\u00edm t\u1eaft Alt + F11<\/li>\n<li>C\u00e1ch 2: Trong tab Developer, b\u1ea5m ch\u1ecdn Visual Basic<\/li>\n<\/ul>\n<h3><span class=\"ez-toc-section\" id=\"Buoc_2_Tao_moi_1_Module\"><\/span>B\u01b0\u1edbc 2: T\u1ea1o m\u1edbi 1 Module<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>B\u1ea5m chu\u1ed9t ph\u1ea3i v\u00e0o m\u1ee5c Project \u2013 VBAProject r\u1ed3i ch\u1ecdn\u00a0Insert \/ Module<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-14446\" src=\"http:\/\/blog.ezworkapp.com\/wp-content\/uploads\/2024\/12\/heo-vba-eval-01-1.png\" width=\"480\" height=\"598\" title=\"heo-vba-eval-01-1\"><\/p>\n<h3><span class=\"ez-toc-section\" id=\"Buoc_3_Tao_ham_trong_VBA_de_tinh_tong_theo_dong_bat_ky\"><\/span>B\u01b0\u1edbc 3: T\u1ea1o\u00a0h\u00e0m trong VBA\u00a0\u0111\u1ec3\u00a0t\u00ednh t\u1ed5ng theo d\u00f2ng b\u1ea5t k\u1ef3<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>Trong Module 1 v\u1eeba t\u1ea1o, ch\u00fang ta d\u00f9ng l\u1ec7nh Function\u00a0\u0111\u1ec3 t\u1ea1o ra 1 h\u00e0m<\/p>\n<div class=\"code-block code-block-2\" style=\"margin: 8px 0;clear: both\">\n<div class=\"ad-inserterpro\">\n<a href=\"https:\/\/hocexcel.online\/course\/preview\/vba101-tu-dong-hoa-excel-voi-lap-trinh-vba-cho-nguoi-moi-bat-dau\"><br \/>\n<img decoding=\"async\" src=\"http:\/\/blog.ezworkapp.com\/wp-content\/uploads\/2024\/12\/vba101_92019-nho-189.gif\" title=\"vba101_92019-nho-189\"><br \/>\n<\/a>\n<\/div>\n<\/div>\n<div class=\"code-block code-block-1\" style=\"margin: 8px 0;clear: both\">\n<div class=\"ad-inserterpro\">\n<a href=\"https:\/\/hocexcel.online\/course\/preview\/ex101-excel-tu-co-ban-den-chuyen-gia-danh-cho-nguoi-di-lam\"><br \/>\n<img decoding=\"async\" src=\"http:\/\/blog.ezworkapp.com\/wp-content\/uploads\/2024\/12\/ex101_92019-nho-467.gif\" title=\"ex101_92019-nho-467\"><br \/>\n<\/a>\n<\/div>\n<\/div>\n<p>\u0110\u1eb7t t\u00ean h\u00e0m l\u00e0 SumByRow (t\u00ednh t\u1ed5ng theo h\u00e0ng)<\/p>\n<p>M\u1ee5c ti\u00eau c\u1ee7a h\u00e0m: T\u00ednh t\u1ed5ng theo 1 d\u00f2ng b\u1ea5t k\u1ef3 trong m\u1ea3ng<\/p>\n<p>Do\u00a0\u0111\u00f3 c\u00f3 2\u00a0\u0111\u1ed1i t\u01b0\u1ee3ng c\u1ea7n s\u1eed d\u1ee5ng trong h\u00e0m: M\u1ea3ng n\u00e0o (Range) v\u00e0 D\u00f2ng n\u00e0o (Row)<\/p>\n<p>C\u00e1ch vi\u1ebft h\u00e0m nh\u01b0 sau:<\/p>\n<\/p>\n<div class=\"oembed-gist\">View the code on <a href=\"https:\/\/gist.github.com\/DuongAQ\/9dc1ed4a0def8bc849d0a17bb3b9c30a\">Gist<\/a>.<\/div>\n<p>\u0110\u1ec3 t\u00ednh cho\u00a0\u0111\u1ed1i t\u01b0\u1ee3ng l\u00e0 C\u1ed9t th\u00ec ch\u00fang ta s\u1eed d\u1ee5ng\u00a0\u0111\u1ed1i t\u01b0\u1ee3ng Column (vi\u1ebft t\u1eaft l\u00e0 col). Khi\u00a0\u0111\u00f3 trong ph\u1ea7n Index c\u1ea7n thay\u00a0\u0111\u1ed5i nh\u01b0 sau:<\/p>\n<\/p>\n<div class=\"oembed-gist\">View the code on <a href=\"https:\/\/gist.github.com\/DuongAQ\/1cef5eeb62655edc0a0ab3055a4aac16\">Gist<\/a>.<\/div>\n<h3><span class=\"ez-toc-section\" id=\"Buoc_4_Cach_su_dung_ham\"><\/span>B\u01b0\u1edbc 4: C\u00e1ch s\u1eed d\u1ee5ng h\u00e0m<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-14454\" src=\"http:\/\/blog.ezworkapp.com\/wp-content\/uploads\/2024\/12\/heo-ham-tinh-tong-theo-mang-02.png\" width=\"564\" height=\"283\" title=\"heo-ham-tinh-tong-theo-mang-02\"><\/p>\n<p>Mu\u1ed1n t\u00ednh t\u1ed5ng theo c\u1ed9t n\u00e0o, s\u1eed d\u1ee5ng h\u00e0m SumByCol v\u00e0 x\u00e1c\u00a0\u0111\u1ecbnh th\u1ee9 t\u1ef1 c\u1ed9t c\u1ea7n t\u00ednh t\u1ed5ng trong m\u1ea3ng\u00a0\u0111\u00f3<\/p>\n<p>Mu\u1ed1n t\u00ednh t\u1ed5ng theo h\u00e0ng n\u00e0o, s\u1eed d\u1ee5ng h\u00e0m SumByRow v\u00e0 x\u00e1c\u00a0\u0111\u1ecbnh th\u1ee9 t\u1ef1 d\u00f2ng c\u1ea7n t\u00ednh t\u1ed5ng trong m\u1ea3ng\u00a0\u0111\u00f3.<\/p>\n<p><em><strong>Video h\u01b0\u1edbng d\u1eabn:<\/strong><\/em><\/p>\n<iframe loading=\"lazy\" title=\"Ha\u0300m SumByRow ti\u0301nh to\u0302\u0309ng theo do\u0300ng ba\u0302\u0301t ki\u0300 trong ma\u0309ng trong VBA\" width=\"500\" height=\"281\" src=\"https:\/\/www.youtube.com\/embed\/1iiKe4dD5_I?feature=oembed\" frameborder allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen><\/iframe>\n<p>Ch\u00fac c\u00e1c b\u1ea1n h\u1ecdc t\u1ed1t c\u00f9ng H\u1ecdc\u00a0Excel Online!<\/p>\n<\/div>\n<div class=\"uk-panel uk-margin uk-width-xlarge\">\n<p>Click \u0111\u0103ng k\u00fd h\u1ecdc t\u1ea1i:<\/p>\n<p><a href=\"http:\/\/blog.ezworkapp.com\/khoa-hoc\" target=\"_blank\" rel=\"noopener\">T\u1ea5t c\u1ea3 kho\u00e1 h\u1ecdc\u00a0<span>\ud83d\udcd6<\/span><\/a><\/p>\n<p><a href=\"http:\/\/blog.ezworkapp.com\/huong-dan-kich-hoat-khoa-hoc-tai-hoc-excel-online.html\" target=\"_blank\" rel=\"noopener\">H\u01b0\u1edbng d\u1eabn k\u00edch ho\u1ea1t<\/a><\/p>\n<p>HKD H\u1ecdc Excel Online<br \/>S\u1ed1 \u0110K: 17A80048102<\/p>\n<\/div>\n<div class=\"uk-panel uk-text-small uk-margin uk-margin-remove-bottom uk-text-center\">\n<p>\u00a9  document.currentScript.insertAdjacentHTML(&#8216;afterend&#8217;, &#8221; + new Intl.DateTimeFormat(document.documentElement.lang, {year: &#8216;numeric&#8217;}).format() + &#8221;);  H\u1ecdc Excel Online. All rights reserved.<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<div class=\"ad-inserterpro\">\n<a href=\"https:\/\/hocexcel.online\/course\/preview\/vba101-tu-dong-hoa-excel-voi-lap-trinh-vba-cho-nguoi-moi-bat-dau\"><br \/>\n<img decoding=\"async\" src=\"http:\/\/blog.ezworkapp.com\/wp-content\/uploads\/2024\/12\/vba101_92019-nho-189.gif\"><br \/>\n<\/a>\n<\/div>\n","protected":false},"author":1,"featured_media":5407,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-5406","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-excel-nang-cao"],"_links":{"self":[{"href":"https:\/\/blog.ezworkapp.com\/index.php\/wp-json\/wp\/v2\/posts\/5406","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.ezworkapp.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.ezworkapp.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.ezworkapp.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.ezworkapp.com\/index.php\/wp-json\/wp\/v2\/comments?post=5406"}],"version-history":[{"count":0,"href":"https:\/\/blog.ezworkapp.com\/index.php\/wp-json\/wp\/v2\/posts\/5406\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.ezworkapp.com\/index.php\/wp-json\/wp\/v2\/media\/5407"}],"wp:attachment":[{"href":"https:\/\/blog.ezworkapp.com\/index.php\/wp-json\/wp\/v2\/media?parent=5406"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.ezworkapp.com\/index.php\/wp-json\/wp\/v2\/categories?post=5406"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.ezworkapp.com\/index.php\/wp-json\/wp\/v2\/tags?post=5406"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}