{"id":1896,"date":"2024-12-02T06:24:32","date_gmt":"2024-12-02T06:24:32","guid":{"rendered":"https:\/\/blog.ezworkapp.com\/index.php\/2024\/12\/02\/tu-dien-vba-trong-excel-huong-dan-day-du\/"},"modified":"2024-12-02T06:24:32","modified_gmt":"2024-12-02T06:24:32","slug":"tu-dien-vba-trong-excel-huong-dan-day-du","status":"publish","type":"post","link":"https:\/\/blog.ezworkapp.com\/index.php\/2024\/12\/02\/tu-dien-vba-trong-excel-huong-dan-day-du\/","title":{"rendered":"T\u1eea \u0110I\u1ec2N VBA TRONG EXCEL \u2013 H\u01af\u1edaNG D\u1eaaN \u0110\u1ea6Y \u0110\u1ee6"},"content":{"rendered":"<div class=\"uk-panel uk-margin\" id=\"template-dQf5b79p#1\">\n<p><em><span style=\"font-weight: 400\">\u201cKi\u1ec7t t\u00e1c v\u0129 \u0111\u1ea1i nh\u1ea5t trong v\u0103n h\u1ecdc ch\u1ec9 l\u00e0 m\u1ed9t cu\u1ed1n t\u1eeb \u0111i\u1ec3n kh\u00f4ng theo tr\u1eadt t\u1ef1.\u201d\u00a0 \u2013 Jean Cocteau.\u00a0 Trong b\u00e0i vi\u1ebft n\u00e0y, <a href=\"http:\/\/blog.ezworkapp.com\/\"><strong>H\u1ecdc Excel Online<\/strong><\/a> s\u1ebd h\u01b0\u1edbng d\u1eabn b\u1ea1n <strong>t\u1eeb \u0111i\u1ec3n VBA\u00a0 trong Excel<\/strong>\u00a0 ngay sau \u0111\u00e2y.<\/span><\/em><\/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-674d529f20ca7\" 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-2\"><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/blog.hocexcel.online\/tu-dien-vba-trong-excel-huong-dan-day-du.html#Huong_dan_nhanh_ve_tu_dien_VBA\" title=\"H\u01b0\u1edbng d\u1eabn nhanh v\u1ec1 t\u1eeb \u0111i\u1ec3n VBA\">H\u01b0\u1edbng d\u1eabn nhanh v\u1ec1 t\u1eeb \u0111i\u1ec3n VBA<\/a><\/li>\n<li class=\"ez-toc-page-1 ez-toc-heading-level-2\"><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/blog.hocexcel.online\/tu-dien-vba-trong-excel-huong-dan-day-du.html#Tu_dien_VBA_la_gi\" title=\"T\u1eeb \u0111i\u1ec3n VBA l\u00e0 g\u00ec?\">T\u1eeb \u0111i\u1ec3n VBA l\u00e0 g\u00ec?<\/a>\n<ul class=\"ez-toc-list-level-3\">\n<li class=\"ez-toc-heading-level-3\"><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/blog.hocexcel.online\/tu-dien-vba-trong-excel-huong-dan-day-du.html#Tu_dien_trong_thuc_te\" title=\"T\u1eeb \u0111i\u1ec3n trong th\u1ef1c t\u1ebf\">T\u1eeb \u0111i\u1ec3n trong th\u1ef1c t\u1ebf<\/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\/tu-dien-vba-trong-excel-huong-dan-day-du.html#Mot_vi_du_don_gian_ve_cach_su_dung_tu_dien_VBA\" title=\"M\u1ed9t v\u00ed d\u1ee5 \u0111\u01a1n gi\u1ea3n v\u1ec1 c\u00e1ch s\u1eed d\u1ee5ng t\u1eeb \u0111i\u1ec3n VBA\">M\u1ed9t v\u00ed d\u1ee5 \u0111\u01a1n gi\u1ea3n v\u1ec1 c\u00e1ch s\u1eed d\u1ee5ng t\u1eeb \u0111i\u1ec3n VBA<\/a><\/li>\n<li class=\"ez-toc-page-1 ez-toc-heading-level-3\"><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/blog.hocexcel.online\/tu-dien-vba-trong-excel-huong-dan-day-du.html#Tao_tu_dien\" title=\"T\u1ea1o t\u1eeb \u0111i\u1ec3n\">T\u1ea1o t\u1eeb \u0111i\u1ec3n<\/a><\/li>\n<\/ul>\n<\/li>\n<li class=\"ez-toc-page-1 ez-toc-heading-level-2\"><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/blog.hocexcel.online\/tu-dien-vba-trong-excel-huong-dan-day-du.html#Early_vs_Late_Binding\" title=\"Early vs Late Binding\">Early vs Late Binding<\/a>\n<ul class=\"ez-toc-list-level-3\">\n<li class=\"ez-toc-heading-level-3\"><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/blog.hocexcel.online\/tu-dien-vba-trong-excel-huong-dan-day-du.html#Chi_dinh_mot_gia_tri\" title=\"Ch\u1ec9 \u0111\u1ecbnh m\u1ed9t gi\u00e1 tr\u1ecb\">Ch\u1ec9 \u0111\u1ecbnh m\u1ed9t gi\u00e1 tr\u1ecb<\/a><\/li>\n<li class=\"ez-toc-page-1 ez-toc-heading-level-3\"><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/blog.hocexcel.online\/tu-dien-vba-trong-excel-huong-dan-day-du.html#Kiem_tra_Key_ton_tai\" title=\"Ki\u1ec3m tra Key t\u1ed3n t\u1ea1i\">Ki\u1ec3m tra Key t\u1ed3n t\u1ea1i<\/a><\/li>\n<li class=\"ez-toc-page-1 ez-toc-heading-level-3\"><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/blog.hocexcel.online\/tu-dien-vba-trong-excel-huong-dan-day-du.html#Luu_tru_nhieu_gia_tri_trong_Key\" title=\"L\u01b0u tr\u1eef nhi\u1ec1u gi\u00e1 tr\u1ecb trong Key\">L\u01b0u tr\u1eef nhi\u1ec1u gi\u00e1 tr\u1ecb trong Key<\/a><\/li>\n<li class=\"ez-toc-page-1 ez-toc-heading-level-3\"><a class=\"ez-toc-link ez-toc-heading-10\" href=\"https:\/\/blog.hocexcel.online\/tu-dien-vba-trong-excel-huong-dan-day-du.html#Cac_chuc_nang_huu_ich_khac\" title=\"C\u00e1c ch\u1ee9c n\u0103ng h\u1eefu \u00edch kh\u00e1c\">C\u00e1c ch\u1ee9c n\u0103ng h\u1eefu \u00edch kh\u00e1c<\/a><\/li>\n<li class=\"ez-toc-page-1 ez-toc-heading-level-3\"><a class=\"ez-toc-link ez-toc-heading-11\" href=\"https:\/\/blog.hocexcel.online\/tu-dien-vba-trong-excel-huong-dan-day-du.html#Key_va_chu_hoa_chu_thuong\" title=\"Key v\u00e0 ch\u1eef hoa ch\u1eef th\u01b0\u1eddng\">Key v\u00e0 ch\u1eef hoa ch\u1eef th\u01b0\u1eddng<\/a><\/li>\n<\/ul>\n<\/li>\n<li class=\"ez-toc-page-1 ez-toc-heading-level-2\"><a class=\"ez-toc-link ez-toc-heading-12\" href=\"https:\/\/blog.hocexcel.online\/tu-dien-vba-trong-excel-huong-dan-day-du.html#Nhung_dieu_can_chu_y\" title=\"Nh\u1eefng \u0111i\u1ec1u c\u1ea7n ch\u00fa \u00fd\">Nh\u1eefng \u0111i\u1ec1u c\u1ea7n ch\u00fa \u00fd<\/a>\n<ul class=\"ez-toc-list-level-3\">\n<li class=\"ez-toc-heading-level-3\"><a class=\"ez-toc-link ez-toc-heading-13\" href=\"https:\/\/blog.hocexcel.online\/tu-dien-vba-trong-excel-huong-dan-day-du.html#Doc_qua_tu_dien\" title=\"\u0110\u1ecdc qua t\u1eeb \u0111i\u1ec3n\">\u0110\u1ecdc qua t\u1eeb \u0111i\u1ec3n<\/a><\/li>\n<li class=\"ez-toc-page-1 ez-toc-heading-level-3\"><a class=\"ez-toc-link ez-toc-heading-14\" href=\"https:\/\/blog.hocexcel.online\/tu-dien-vba-trong-excel-huong-dan-day-du.html#Sap_xep_theo_key\" title=\"S\u1eafp x\u1ebfp theo key\">S\u1eafp x\u1ebfp theo key<\/a><\/li>\n<li class=\"ez-toc-page-1 ez-toc-heading-level-3\"><a class=\"ez-toc-link ez-toc-heading-15\" href=\"https:\/\/blog.hocexcel.online\/tu-dien-vba-trong-excel-huong-dan-day-du.html#Sap_xep_bang_gia_tri\" title=\"S\u1eafp x\u1ebfp b\u1eb1ng gi\u00e1 tr\u1ecb\">S\u1eafp x\u1ebfp b\u1eb1ng gi\u00e1 tr\u1ecb<\/a><\/li>\n<li class=\"ez-toc-page-1 ez-toc-heading-level-3\"><a class=\"ez-toc-link ez-toc-heading-16\" href=\"https:\/\/blog.hocexcel.online\/tu-dien-vba-trong-excel-huong-dan-day-du.html#Giai_quyet_rac_roi_tu_dien\" title=\"Gi\u1ea3i quy\u1ebft r\u1eafc r\u1ed1i t\u1eeb \u0111i\u1ec3n\">Gi\u1ea3i quy\u1ebft r\u1eafc r\u1ed1i t\u1eeb \u0111i\u1ec3n<\/a><\/li>\n<li class=\"ez-toc-page-1 ez-toc-heading-level-3\"><a class=\"ez-toc-link ez-toc-heading-17\" href=\"https:\/\/blog.hocexcel.online\/tu-dien-vba-trong-excel-huong-dan-day-du.html#Quen_tham_chieu\" title=\"Qu\u00ean tham chi\u1ebfu\">Qu\u00ean tham chi\u1ebfu<\/a><\/li>\n<li class=\"ez-toc-page-1 ez-toc-heading-level-3\"><a class=\"ez-toc-link ez-toc-heading-18\" href=\"https:\/\/blog.hocexcel.online\/tu-dien-vba-trong-excel-huong-dan-day-du.html#Exists_khong_hoat_dong\" title=\"Exists kh\u00f4ng ho\u1ea1t \u0111\u1ed9ng\">Exists kh\u00f4ng ho\u1ea1t \u0111\u1ed9ng<\/a><\/li>\n<li class=\"ez-toc-page-1 ez-toc-heading-level-3\"><a class=\"ez-toc-link ez-toc-heading-19\" href=\"https:\/\/blog.hocexcel.online\/tu-dien-vba-trong-excel-huong-dan-day-du.html#Loi_bieu_tuong\" title=\"L\u1ed7i bi\u1ec3u t\u01b0\u1ee3ng\">L\u1ed7i bi\u1ec3u t\u01b0\u1ee3ng<\/a><\/li>\n<li class=\"ez-toc-page-1 ez-toc-heading-level-3\"><a class=\"ez-toc-link ez-toc-heading-20\" href=\"https:\/\/blog.hocexcel.online\/tu-dien-vba-trong-excel-huong-dan-day-du.html#Meo_huu_ich_de_go_roi_tu_dien\" title=\"M\u1eb9o h\u1eefu \u00edch \u0111\u1ec3 g\u1ee1 r\u1ed1i t\u1eeb \u0111i\u1ec3n\">M\u1eb9o h\u1eefu \u00edch \u0111\u1ec3 g\u1ee1 r\u1ed1i t\u1eeb \u0111i\u1ec3n<\/a><\/li>\n<\/ul>\n<\/li>\n<li class=\"ez-toc-page-1 ez-toc-heading-level-2\"><a class=\"ez-toc-link ez-toc-heading-21\" href=\"https:\/\/blog.hocexcel.online\/tu-dien-vba-trong-excel-huong-dan-day-du.html#Sao_chep_tu_dien_vao_mot_mang\" title=\"Sao ch\u00e9p t\u1eeb \u0111i\u1ec3n v\u00e0o m\u1ed9t m\u1ea3ng\">Sao ch\u00e9p t\u1eeb \u0111i\u1ec3n v\u00e0o m\u1ed9t m\u1ea3ng<\/a>\n<ul class=\"ez-toc-list-level-3\">\n<li class=\"ez-toc-heading-level-3\"><a class=\"ez-toc-link ez-toc-heading-22\" href=\"https:\/\/blog.hocexcel.online\/tu-dien-vba-trong-excel-huong-dan-day-du.html#Viet_tu_dien_vao_trang_tinh\" title=\"Vi\u1ebft t\u1eeb \u0111i\u1ec3n v\u00e0o trang t\u00ednh\">Vi\u1ebft t\u1eeb \u0111i\u1ec3n v\u00e0o trang t\u00ednh<\/a><\/li>\n<\/ul>\n<\/li>\n<li class=\"ez-toc-page-1 ez-toc-heading-level-2\"><a class=\"ez-toc-link ez-toc-heading-23\" href=\"https:\/\/blog.hocexcel.online\/tu-dien-vba-trong-excel-huong-dan-day-du.html#Vi_du_huu_ich_ve_tu_dien\" title=\"V\u00ed d\u1ee5 h\u1eefu \u00edch v\u1ec1 t\u1eeb \u0111i\u1ec3n\">V\u00ed d\u1ee5 h\u1eefu \u00edch v\u1ec1 t\u1eeb \u0111i\u1ec3n<\/a>\n<ul class=\"ez-toc-list-level-3\">\n<li class=\"ez-toc-heading-level-3\"><a class=\"ez-toc-link ez-toc-heading-24\" href=\"https:\/\/blog.hocexcel.online\/tu-dien-vba-trong-excel-huong-dan-day-du.html#Vi_du_1_%E2%80%93_Tong_gia_tri_don\" title=\"V\u00ed d\u1ee5 1 \u2013 T\u1ed5ng gi\u00e1 tr\u1ecb \u0111\u01a1n\">V\u00ed d\u1ee5 1 \u2013 T\u1ed5ng gi\u00e1 tr\u1ecb \u0111\u01a1n<\/a><\/li>\n<li class=\"ez-toc-page-1 ez-toc-heading-level-3\"><a class=\"ez-toc-link ez-toc-heading-25\" href=\"https:\/\/blog.hocexcel.online\/tu-dien-vba-trong-excel-huong-dan-day-du.html#Vi_du_2_%E2%80%93_Xu_ly_nhieu_gia_tri\" title=\"V\u00ed d\u1ee5 2 \u2013 X\u1eed l\u00fd nhi\u1ec1u gi\u00e1 tr\u1ecb\">V\u00ed d\u1ee5 2 \u2013 X\u1eed l\u00fd nhi\u1ec1u gi\u00e1 tr\u1ecb<\/a><\/li>\n<li class=\"ez-toc-page-1 ez-toc-heading-level-3\"><a class=\"ez-toc-link ez-toc-heading-26\" href=\"https:\/\/blog.hocexcel.online\/tu-dien-vba-trong-excel-huong-dan-day-du.html#Vi_du_3_%E2%80%93_Tinh_tong_nhieu_gia_tri\" title=\"V\u00ed d\u1ee5 3 \u2013 T\u00ednh t\u1ed5ng nhi\u1ec1u gi\u00e1 tr\u1ecb\u00a0\">V\u00ed d\u1ee5 3 \u2013 T\u00ednh t\u1ed5ng nhi\u1ec1u gi\u00e1 tr\u1ecb\u00a0<\/a><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/nav>\n<\/div>\n<h2><span class=\"ez-toc-section\" id=\"Huong_dan_nhanh_ve_tu_dien_VBA\"><\/span><b>H\u01b0\u1edbng d\u1eabn nhanh v\u1ec1 t\u1eeb \u0111i\u1ec3n VBA<\/b><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<table>\n<tbody>\n<tr>\n<td><span style=\"font-weight: 400\">Ch\u1ee9c n\u0103ng<\/span><\/td>\n<td><span style=\"font-weight: 400\">Params<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">Tham chi\u1ebfu r\u00e0ng bu\u1ed9c<\/span><\/td>\n<td><span style=\"font-weight: 400\">\u201cMicrosoft Scripting Runtime\u201d (Th\u00eam b\u1eb1ng Tools -&gt; References t\u1eeb menu VB)<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">Khai b\u00e1o (early blinding)<\/span><\/td>\n<td><b>Dim<\/b><span style=\"font-weight: 400\"> dict <\/span><b>As<\/b><span style=\"font-weight: 400\"> Scripting.Dictionary<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">T\u1ea1o (Early blinding)<\/span><\/td>\n<td><b>Set<\/b><span style=\"font-weight: 400\"> dict =<\/span><b> New<\/b><span style=\"font-weight: 400\"> Scripting.Dictionary<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">Khai b\u00e1o (Late binding)<\/span><\/td>\n<td><b>Dim<\/b><span style=\"font-weight: 400\"> dict <\/span><b>As Object<\/b><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">T\u1ea1o (Late binding)<\/span><\/td>\n<td><span style=\"font-weight: 400\">Set dict = CreateObject(\u201cScripting.Dictionary\u201d)<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">Th\u00eam Item (Key kh\u00f4ng \u0111\u01b0\u1ee3c t\u1ed3n t\u1ea1i)<\/span><\/td>\n<td><span style=\"font-weight: 400\">dict.Add Key, Value<\/span><\/p>\n<p><span style=\"font-weight: 400\">e.g. dict.Add <\/span><b>\u201cApples\u201d<\/b><span style=\"font-weight: 400\">, 50<\/span><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">Thay \u0111\u1ed5i gi\u00e1 tr\u1ecb t\u1ea1i Key. T\u1ef1 \u0111\u1ed9ng th\u00eam n\u1ebfu Key kh\u00f4ng t\u1ed3n t\u1ea1i.<\/span><\/td>\n<td><span style=\"font-weight: 400\">dict(Key) = Value<\/span><\/p>\n<p><span style=\"font-weight: 400\">e.g. dict(<\/span><b>\u201cOranges\u201d<\/b><span style=\"font-weight: 400\">) = 60<\/span><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">Nh\u1eadn gi\u00e1 tr\u1ecb t\u1eeb t\u1eeb \u0111i\u1ec3n b\u1eb1ng c\u00e1ch s\u1eed d\u1ee5ng Key.<\/span><\/td>\n<td><span style=\"font-weight: 400\">Value<\/span> <span style=\"font-weight: 400\">= dict(Key)<\/span><\/p>\n<p><span style=\"font-weight: 400\">e.g. appleCount = dict(<\/span><b>\u201cApples\u201d<\/b><span style=\"font-weight: 400\">)<\/span><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">Ki\u1ec3m tra xem Key c\u00f3 t\u1ed3n t\u1ea1i kh\u00f4ng.<\/span><\/td>\n<td><span style=\"font-weight: 400\">dict.Exists(Key)<\/span><\/p>\n<p><span style=\"font-weight: 400\">e.g. If dict.Exists(\u201cApples\u201d) Then<\/span><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">X\u00f3a Item<\/span><\/td>\n<td><span style=\"font-weight: 400\">dict.Remove Key<\/span><\/p>\n<p><span style=\"font-weight: 400\">e.g. dict.Remove \u201cApples\u201d<\/span><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">X\u00f3a t\u1ea5t c\u1ea3 c\u00e1c Item<\/span><\/td>\n<td><span style=\"font-weight: 400\">dict.RemoveAll<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">Xem qua t\u1ea5t c\u1ea3 c\u00e1c Item (cho m\u1ed7i v\u00f2ng l\u1eb7p)<\/span><\/td>\n<td><span style=\"font-weight: 400\">Dim key As Variant<\/span><\/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-56.gif\" title=\"vba101_92019-nho-56\"><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-138.gif\" title=\"ex101_92019-nho-138\"><br \/>\n<\/a>\n<\/div>\n<\/div>\n<p><span style=\"font-weight: 400\">For Each key In dict.Keys<\/span><\/p>\n<p><span style=\"font-weight: 400\">\u00a0\u00a0\u00a0\u00a0Debug.Print key, dict(key)<\/span><\/p>\n<p><span style=\"font-weight: 400\">Next key<\/span><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">Xem qua t\u1ea5t c\u1ea3 c\u00e1c Item (cho v\u00f2ng l\u1eb7p \u2013 ch\u1ec9 <\/span><span style=\"font-weight: 400\">early binding<\/span><span style=\"font-weight: 400\">)<\/span><\/td>\n<td><span style=\"font-weight: 400\">Dim i As Long<\/span><\/p>\n<p><span style=\"font-weight: 400\">For i = 0 To dict.Count \u2013 1<\/span><\/p>\n<p><span style=\"font-weight: 400\">\u00a0\u00a0\u00a0Debug.Print dict.Keys(i),\u00a0 \u00a0 \u00a0 dict.Items(i)<\/span><\/p>\n<p><span style=\"font-weight: 400\">Next i<\/span><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">Xem qua t\u1ea5t c\u1ea3 c\u00e1c Item (cho v\u00f2ng l\u1eb7p \u2013 early and late binding)<\/span><\/td>\n<td><span style=\"font-weight: 400\">Dim i As Long<\/span><\/p>\n<p><span style=\"font-weight: 400\">For i = 0 To dict.Count \u2013 1<\/span><\/p>\n<p><span style=\"font-weight: 400\">Debug.Print dict.Keys()(i), dict.Items()(i)<\/span><\/p>\n<p><span style=\"font-weight: 400\">Next i<\/span><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">Nh\u1eadn s\u1ed1 l\u01b0\u1ee3ng Item<\/span><\/td>\n<td><span style=\"font-weight: 400\">dict.Count<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">\u0110\u1eb7t Key ph\u00e2n bi\u1ec7t ch\u1eef hoa ch\u1eef th\u01b0\u1eddng (t\u1eeb \u0111i\u1ec3n ph\u1ea3i tr\u1ed1ng).<\/span><\/td>\n<td><span style=\"font-weight: 400\">dict.CompareMode = vbBinaryCompare<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">\u0110\u1eb7t Key kh\u00f4ng ph\u00e2n bi\u1ec7t ch\u1eef hoa ch\u1eef th\u01b0\u1eddng (t\u1eeb \u0111i\u1ec3n ph\u1ea3i tr\u1ed1ng).<\/span><\/td>\n<td><span style=\"font-weight: 400\">dict.CompareMode = vbTextCompare<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u00a0<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Tu_dien_VBA_la_gi\"><\/span><b>T\u1eeb \u0111i\u1ec3n VBA l\u00e0 g\u00ec?<\/b><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><span style=\"font-weight: 400\">Trong VBA, ch\u00fang ta s\u1eed d\u1ee5ng <\/span><span style=\"font-weight: 400\">M\u1ea3ng<\/span><span style=\"font-weight: 400\"> v\u00e0 Collection \u0111\u1ec3 l\u01b0u tr\u1eef c\u00e1c nh\u00f3m gi\u00e1 tr\u1ecb. V\u00ed d\u1ee5, ch\u00fang ta c\u00f3 th\u1ec3 s\u1eed d\u1ee5ng ch\u00fang \u0111\u1ec3 l\u01b0u tr\u1eef danh s\u00e1ch t\u00ean kh\u00e1ch h\u00e0ng, \u0111i\u1ec3m c\u1ee7a sinh vi\u00ean ho\u1eb7c danh s\u00e1ch c\u00e1c gi\u00e1 tr\u1ecb t\u1eeb m\u1ed9t d\u1ea3i \u00f4.<\/span><\/p>\n<p><span style=\"font-weight: 400\">T\u1eeb \u0111i\u1ec3n t\u01b0\u01a1ng t\u1ef1 nh\u01b0 m\u1ed9t B\u1ed9 s\u01b0u t\u1eadp. S\u1eed d\u1ee5ng c\u1ea3 hai lo\u1ea1i, ch\u00fang ta c\u00f3 th\u1ec3 \u0111\u1eb7t t\u00ean cho m\u1ed9t Item khi ch\u00fang ta th\u00eam n\u00f3. H\u00e3y t\u01b0\u1edfng t\u01b0\u1ee3ng ch\u00fang ta \u0111ang l\u01b0u tr\u1eef s\u1ed1 l\u01b0\u1ee3ng c\u00e1c lo\u1ea1i tr\u00e1i c\u00e2y kh\u00e1c nhau.<\/span><\/p>\n<p><span style=\"font-weight: 400\">Ch\u00fang ta c\u00f3 th\u1ec3 s\u1eed d\u1ee5ng c\u1ea3 Collection v\u00e0 Dictionary nh\u01b0 th\u1ebf n\u00e0y:<\/span><\/p>\n<pre><strong>' Add to Dictionary\r\ndict.Add Key:=\"Apple\", Item:=5\r\n\r\n' Add to Collection\r\ncoll.Add Item:=5, Key:=\"Apple\"\r\n<\/strong><\/pre>\n<figure id=\"attachment_34181\" aria-describedby=\"caption-attachment-34181\" style=\"width: 300px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-34181\" src=\"http:\/\/blog.ezworkapp.com\/wp-content\/uploads\/2024\/12\/1-tu-dien-vba-trong-excel.png\" alt=\"1-T\u1eea \u0110I\u1ec2N VBA TRONG EXCEL\" width=\"300\" height=\"253\" title=\"1-tu-dien-vba-trong-excel\"><figcaption id=\"caption-attachment-34181\" class=\"wp-caption-text\">1-T\u1eea \u0110I\u1ec2N VBA TRONG EXCEL<\/figcaption><\/figure>\n<pre><strong>\u00a0<\/strong><\/pre>\n<p><span style=\"font-weight: 400\">Trong c\u1ea3 hai tr\u01b0\u1eddng h\u1ee3p, ch\u00fang ta \u0111ang l\u01b0u tr\u1eef gi\u00e1 tr\u1ecb 5 v\u00e0 \u0111\u1eb7t t\u00ean cho n\u00f3 l\u00e0 \u201cApple\u201d. B\u00e2y gi\u1edd ch\u00fang ta c\u00f3 th\u1ec3 nh\u1eadn \u0111\u01b0\u1ee3c gi\u00e1 tr\u1ecb c\u1ee7a Apple t\u1eeb c\u1ea3 hai lo\u1ea1i nh\u01b0 th\u1ebf n\u00e0y:<\/span><\/p>\n<pre><strong>' Get value from Dictionary\r\nTotal = dict(\"Apple\")\r\n\r\n' Get value from Collection\r\nTotal = coll(\"Apple\")<\/strong><\/pre>\n<p><span style=\"font-weight: 400\">C\u00e0ng xa c\u00e0ng t\u1ed1t. Tuy nhi\u00ean, Collection c\u00f3 hai nh\u01b0\u1ee3c\u00a0 \u0111i\u1ec3m ch\u00ednh:<\/span><\/p>\n<ol>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">Ch\u00fang ta kh\u00f4ng th\u1ec3 ki\u1ec3m tra xem Key \u0111\u00e3 t\u1ed3n t\u1ea1i hay ch\u01b0a.\u00a0\u00a0<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">Ch\u00fang ta kh\u00f4ng th\u1ec3 thay \u0111\u1ed5i gi\u00e1 tr\u1ecb c\u1ee7a m\u1ed9t m\u1eb7t h\u00e0ng hi\u1ec7n c\u00f3.<\/span><\/li>\n<\/ol>\n<p><span style=\"font-weight: 400\">V\u1ea5n \u0111\u1ec1 \u0111\u1ea7u ti\u00ean kh\u00e1 d\u1ec5 g\u1eb7p ph\u1ea3i: <\/span><span style=\"font-weight: 400\">\u00a0Check Collection Key exists<\/span><span style=\"font-weight: 400\">. Th\u1ee9 hai th\u00ec kh\u00f3 h\u01a1n.<\/span><\/p>\n<p><span style=\"font-weight: 400\">T\u1eeb \u0111i\u1ec3n VBA kh\u00f4ng c\u00f3 nh\u1eefng v\u1ea5n \u0111\u1ec1 n\u00e0y. B\u1ea1n c\u00f3 th\u1ec3 ki\u1ec3m tra xem Key c\u00f3 t\u1ed3n t\u1ea1i hay kh\u00f4ng v\u00e0 b\u1ea1n c\u00f3 th\u1ec3 thay \u0111\u1ed5i Item v\u00e0 Key.<\/span><\/p>\n<p><span style=\"font-weight: 400\">V\u00ed d\u1ee5: ch\u00fang ta c\u00f3 th\u1ec3 s\u1eed d\u1ee5ng m\u00e3 sau \u0111\u1ec3 ki\u1ec3m tra xem ch\u00fang ta c\u00f3 m\u1ed9t m\u1eb7t h\u00e0ng t\u00ean l\u00e0 Apple hay kh\u00f4ng.<\/span><\/p>\n<pre><strong>If dict.Exists(\"Apple\") Then \r\n    dict(\"Apple\") = 78<\/strong><\/pre>\n<p><span style=\"font-weight: 400\">Nh\u1eefng kh\u00e1c bi\u1ec7t n\u00e0y c\u00f3 v\u1ebb r\u1ea5t \u0111\u01a1n gi\u1ea3n. Tuy nhi\u00ean, n\u00f3 c\u00f3 ngh\u0129a l\u00e0 T\u1eeb \u0111i\u1ec3n r\u1ea5t h\u1eefu \u00edch cho m\u1ed9t s\u1ed1 nhi\u1ec7m v\u1ee5 nh\u1ea5t \u0111\u1ecbnh. \u0110\u1eb7c bi\u1ec7t l\u00e0 khi ch\u00fang ta c\u1ea7n l\u1ea5y gi\u00e1 tr\u1ecb c\u1ee7a m\u1ed9t Item.<\/span><\/p>\n<h3><span class=\"ez-toc-section\" id=\"Tu_dien_trong_thuc_te\"><\/span><b>T\u1eeb \u0111i\u1ec3n trong th\u1ef1c t\u1ebf<\/b><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><span style=\"font-weight: 400\">N\u1ebfu b\u1ea1n v\u1eabn ch\u01b0a hi\u1ec3u r\u00f5 v\u1ec1 T\u1eeb \u0111i\u1ec3n th\u00ec h\u00e3y ngh\u0129 theo c\u00e1ch n\u00e0y. M\u1ed9t t\u1eeb \u0111i\u1ec3n tr\u00ean th\u1ef1c t\u1ebf c\u00f3 m\u1ed9t danh s\u00e1ch c\u00e1c Key v\u00e0 c\u00e1c Item. C\u00e1c Key l\u00e0 c\u00e1c t\u1eeb v\u00e0 c\u00e1c Item l\u00e0 \u0111\u1ecbnh ngh\u0129a.<\/span><\/p>\n<p><span style=\"font-weight: 400\">Khi b\u1ea1n mu\u1ed1n t\u00ecm \u0111\u1ecbnh ngh\u0129a c\u1ee7a m\u1ed9t t\u1eeb, b\u1ea1n chuy\u1ec3n th\u1eb3ng \u0111\u1ebfn t\u1eeb \u0111\u00f3. B\u1ea1n kh\u00f4ng \u0111\u1ecdc h\u1ebft m\u1ecdi Item trong T\u1eeb \u0111i\u1ec3n.<\/span><\/p>\n<p><span style=\"font-weight: 400\">M\u1ed9t v\u00ed d\u1ee5 th\u1ee9 hai trong th\u1ef1c t\u1ebf l\u00e0 m\u1ed9t danh b\u1ea1 \u0111i\u1ec7n tho\u1ea1i (b\u1ea1n c\u00f3 nh\u1edb kh\u00f4ng?). Key trong danh b\u1ea1 \u0111i\u1ec7n tho\u1ea1i l\u00e0 t\u00ean  \u0111\u1ecba ch\u1ec9 v\u00e0 Item l\u00e0 s\u1ed1 \u0111i\u1ec7n tho\u1ea1i.\u00a0 M\u1ed9t l\u1ea7n n\u1eefa, b\u1ea1n s\u1eed d\u1ee5ng t\u1ed5 h\u1ee3p t\u00ean  \u0111\u1ecba ch\u1ec9 \u0111\u1ec3 nhanh ch\u00f3ng t\u00ecm th\u1ea5y m\u1ed9t s\u1ed1 \u0111i\u1ec7n tho\u1ea1i.<\/span><\/p>\n<p><span style=\"font-weight: 400\">Trong Excel, h\u00e0m VLookup ho\u1ea1t \u0111\u1ed9ng theo c\u00e1ch t\u01b0\u01a1ng t\u1ef1 nh\u01b0 m\u1ed9t T\u1eeb \u0111i\u1ec3n. B\u1ea1n t\u00ecm ki\u1ebfm m\u1ed9t m\u1eb7t h\u00e0ng d\u1ef1a tr\u00ean m\u1ed9t gi\u00e1 tr\u1ecb duy nh\u1ea5t.<\/span><\/p>\n<h3><span class=\"ez-toc-section\" id=\"Mot_vi_du_don_gian_ve_cach_su_dung_tu_dien_VBA\"><\/span><b>M\u1ed9t v\u00ed d\u1ee5 \u0111\u01a1n gi\u1ea3n v\u1ec1 c\u00e1ch s\u1eed d\u1ee5ng t\u1eeb \u0111i\u1ec3n VBA<\/b><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><span style=\"font-weight: 400\">\u0110o\u1ea1n m\u00e3 d\u01b0\u1edbi \u0111\u00e2y \u0111\u01b0a ra m\u1ed9t v\u00ed d\u1ee5 \u0111\u01a1n gi\u1ea3n v\u1ec1 vi\u1ec7c s\u1eed d\u1ee5ng T\u1eeb \u0111i\u1ec3n. N\u00f3 l\u00e0m nh\u01b0 sau:<\/span><\/p>\n<ol>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">Th\u00eam ba lo\u1ea1i tr\u00e1i c\u00e2y v\u00e0 m\u1ed9t gi\u00e1 tr\u1ecb cho m\u1ed7i lo\u1ea1i v\u00e0o T\u1eeb \u0111i\u1ec3n.\u00a0\u00a0<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">Ng\u01b0\u1eddi d\u00f9ng \u0111\u01b0\u1ee3c y\u00eau c\u1ea7u nh\u1eadp t\u00ean c\u1ee7a m\u1ed9t lo\u1ea1i tr\u00e1i c\u00e2y.\u00a0\u00a0<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">M\u00e3 ki\u1ec3m tra xem qu\u1ea3 n\u00e0y c\u00f3 trong T\u1eeb \u0111i\u1ec3n hay kh\u00f4ng.\u00a0\u00a0<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">N\u1ebfu c\u00f3 th\u00ec n\u00f3 s\u1ebd hi\u1ec3n th\u1ecb t\u00ean tr\u00e1i c\u00e2y v\u00e0 gi\u00e1 tr\u1ecb.\u00a0\u00a0<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">N\u1ebfu kh\u00f4ng th\u00ec n\u00f3 s\u1ebd th\u00f4ng b\u00e1o cho ng\u01b0\u1eddi d\u00f9ng r\u1eb1ng tr\u00e1i c\u00e2y kh\u00f4ng t\u1ed3n t\u1ea1i.<\/span><\/li>\n<\/ol>\n<pre><strong>' https:\/\/excelmacromastery.com\/\r\nSub CheckFruit()\r\n\r\n    ' Select Tools-&gt;References from the Visual Basic menu.\r\n    ' Check box beside \"Microsoft Scripting Runtime\" in the list.\r\n    Dim dict As New Scripting.Dictionary\r\n    \r\n    ' Add to fruit to Dictionary\r\n    dict.Add key:=\"Apple\", Item:=51\r\n    dict.Add key:=\"Peach\", Item:=34\r\n    dict.Add key:=\"Plum\", Item:=43\r\n\r\n    Dim sFruit As String\r\n    ' Ask user to enter fruit\r\n    sFruit = InputBox(\"Please enter the name of a fruit\")\r\n\r\n    If dict.Exists(sFruit) Then\r\n        MsgBox sFruit &amp; \" exists and has value \" &amp; dict(sFruit)\r\n    Else\r\n        MsgBox sFruit &amp; \" does not exist.\"\r\n    End If\r\n    \r\n    Set dict = Nothing\r\n    \r\nEnd Sub<\/strong><\/pre>\n<p><span style=\"font-weight: 400\">\u0110\u00e2y l\u00e0 m\u1ed9t v\u00ed d\u1ee5 \u0111\u01a1n gi\u1ea3n nh\u01b0ng n\u00f3 cho th\u1ea5y t\u1eeb \u0111i\u1ec3n h\u1eefu \u00edch nh\u01b0 th\u1ebf n\u00e0o. Ch\u00fang ta s\u1ebd xem m\u1ed9t v\u00ed d\u1ee5 th\u1ef1c \u1edf ph\u1ea7n sau c\u1ee7a b\u00e0i vi\u1ebft. H\u00e3y xem x\u00e9t nh\u1eefng \u0111i\u1ec1u c\u01a1 b\u1ea3n c\u1ee7a vi\u1ec7c s\u1eed d\u1ee5ng T\u1eeb \u0111i\u1ec3n.<\/span><\/p>\n<h3><span class=\"ez-toc-section\" id=\"Tao_tu_dien\"><\/span><b>T\u1ea1o t\u1eeb \u0111i\u1ec3n<\/b><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><span style=\"font-weight: 400\">\u0110\u1ec3 s\u1eed d\u1ee5ng T\u1eeb \u0111i\u1ec3n, tr\u01b0\u1edbc ti\u00ean b\u1ea1n c\u1ea7n th\u00eam th\u01b0 vi\u1ec7n.<\/span><\/p>\n<ol>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">Ch\u1ecdn <\/span><b>Tools -&gt; References<\/b><span style=\"font-weight: 400\"> t\u1eeb <\/span><span style=\"font-weight: 400\">Visual Basic menu<\/span><span style=\"font-weight: 400\">.\u00a0\u00a0<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">T\u00ecm Microsoft Scripting Runtime trong danh s\u00e1ch v\u00e0 \u0111\u00e1nh d\u1ea5u v\u00e0o h\u1ed9p b\u00ean c\u1ea1nh n\u00f3.<\/span><\/li>\n<\/ol>\n<p><span style=\"font-weight: 400\">Ch\u00fang ta khai b\u00e1o m\u1ed9t t\u1eeb \u0111i\u1ec3n nh\u01b0 sau:<\/span><\/p>\n<pre><strong>Dim dict As New Scripting.Dictionary\r\n<\/strong><\/pre>\n<p><span style=\"font-weight: 400\">Hay\u00a0<\/span><\/p>\n<pre><strong>Dim dict As Scripting.Dictionary\r\nSet dict = New Scripting.Dictionary<\/strong><\/pre>\n<p><span style=\"font-weight: 400\">T\u1ea1o t\u1eeb \u0111i\u1ec3n theo c\u00e1ch n\u00e0y \u0111\u01b0\u1ee3c g\u1ecdi l\u00e0 \u201cEarly Binding\u201d. Ngo\u00e0i ra c\u00f2n c\u00f3 \u201cLate Binding\u201d. H\u00e3y xem \u0111i\u1ec1u n\u00e0y c\u00f3 ngh\u0129a l\u00e0 g\u00ec.<\/span><\/p>\n<h2><span class=\"ez-toc-section\" id=\"Early_vs_Late_Binding\"><\/span><b>Early vs Late Binding<\/b><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><span style=\"font-weight: 400\">\u0110\u1ec3 t\u1ea1o t\u1eeb \u0111i\u1ec3n b\u1eb1ng c\u00e1ch s\u1eed d\u1ee5ng Late Binding, ch\u00fang ta s\u1eed d\u1ee5ng \u0111o\u1ea1n m\u00e3 sau.\u00a0 Ch\u00fang t\u00f4i kh\u00f4ng c\u1ea7n th\u00eam m\u1ed9t tham chi\u1ebfu.<\/span><\/p>\n<pre><strong>Dim dict As Object\r\nSet dict = CreateObject(\"Scripting.Dictionary\")<\/strong><\/pre>\n<p><span style=\"font-weight: 400\">V\u1ec1 m\u1eb7t k\u1ef9 thu\u1eadt <\/span><span style=\"font-weight: 400\">Early binding<\/span><span style=\"font-weight: 400\"> c\u00f3 ngh\u0129a l\u00e0 ch\u00fang ta quy\u1ebft \u0111\u1ecbnh ch\u00ednh x\u00e1c nh\u1eefng g\u00ec ch\u00fang ta \u0111ang s\u1eed d\u1ee5ng t\u1eeb tr\u01b0\u1edbc. V\u1edbi <\/span><span style=\"font-weight: 400\">Late binding<\/span><span style=\"font-weight: 400\">, quy\u1ebft \u0111\u1ecbnh n\u00e0y \u0111\u01b0\u1ee3c th\u1ef1c hi\u1ec7n khi \u1ee9ng d\u1ee5ng \u0111ang ch\u1ea1y. N\u00f3i m\u1ed9t c\u00e1ch d\u1ec5 hi\u1ec3u, s\u1ef1 kh\u00e1c bi\u1ec7t l\u00e0:<\/span><\/p>\n<ol>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">Early binding<\/span><span style=\"font-weight: 400\"> c\u1ea7n c\u00f3 th\u01b0 vi\u1ec7n m\u00e0 ch\u00fang ta ch\u1ecdn \u1edf Tools References\u00a0 . <\/span><span style=\"font-weight: 400\">Late binding th\u00ec kh\u00f4ng.<\/span><span style=\"font-weight: 400\">\u00a0<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">Early binding<\/span><span style=\"font-weight: 400\"> cho ph\u00e9p truy c\u1eadp v\u00e0o <\/span><b>*Intellisense- ch\u1ee9c n\u0103ng g\u1ee3i khi code\/l\u1eadp tr\u00ecnh<\/b><span style=\"font-weight: 400\">. <\/span><span style=\"font-weight: 400\">Late binding th\u00ec kh\u00f4ng.<\/span><span style=\"font-weight: 400\">\u00a0\u00a0<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">Early binding<\/span><span style=\"font-weight: 400\"> c\u00f3 th\u1ec3 y\u00eau c\u1ea7u b\u1ea1n th\u00eam th\u1ee7 c\u00f4ng Tham chi\u1ebfu v\u00e0o \u201cMicrosoft Scripting Runtime\u201d cho m\u1ed9t s\u1ed1 ng\u01b0\u1eddi d\u00f9ng.<\/span><\/li>\n<\/ol>\n<p><span style=\"font-weight: 400\">(*Intellisense l\u00e0 t\u00ednh n\u0103ng hi\u1ec3n th\u1ecb cho b\u1ea1n c\u00e1c th\u1ee7 t\u1ee5c v\u00e0 thu\u1ed9c t\u00ednh c\u00f3 s\u1eb5n c\u1ee7a m\u1ed9t Item khi b\u1ea1n \u0111ang nh\u1eadp.)<\/span><\/p>\n<p><span style=\"font-weight: 400\">M\u1eb7c d\u00f9 Microsoft khuy\u00ean b\u1ea1n n\u00ean s\u1eed d\u1ee5ng <\/span><span style=\"font-weight: 400\">early binding<\/span><span style=\"font-weight: 400\"> trong h\u1ea7u h\u1ebft c\u00e1c tr\u01b0\u1eddng h\u1ee3p, nh\u01b0ng t\u00f4i s\u1ebd kh\u00e1c. M\u1ed9t nguy\u00ean t\u1eafc chung l\u00e0 <\/span><span style=\"font-weight: 400\">early binding<\/span><span style=\"font-weight: 400\"> khi ph\u00e1t tri\u1ec3n m\u00e3 \u0111\u1ec3 b\u1ea1n c\u00f3 quy\u1ec1n truy c\u1eadp v\u00e0o Intellisense. S\u1eed d\u1ee5ng <\/span><span style=\"font-weight: 400\">late binding<\/span><span style=\"font-weight: 400\"> khi ph\u00e2n ph\u1ed1i m\u00e3 cho ng\u01b0\u1eddi d\u00f9ng kh\u00e1c \u0111\u1ec3 ng\u0103n c\u00e1c l\u1ed7i xung \u0111\u1ed9t th\u01b0 vi\u1ec7n kh\u00e1c nhau x\u1ea3y ra.<\/span><\/p>\n<p><span style=\"font-weight: 400\">Th\u00eam c\u00e1c Item v\u00e0o t\u1eeb \u0111i\u1ec3n<\/span><\/p>\n<table>\n<tbody>\n<tr>\n<td><span style=\"font-weight: 400\">Ch\u1ee9c n\u0103ng<\/span><\/td>\n<td><span style=\"font-weight: 400\">Params<\/span><\/td>\n<td><span style=\"font-weight: 400\">V\u00ed d\u1ee5<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">Add<\/span><\/td>\n<td><span style=\"font-weight: 400\">Key, Item<\/span><\/td>\n<td><span style=\"font-weight: 400\">dict.Add <\/span><b>\u201cApples\u201d<\/b><span style=\"font-weight: 400\">, 50<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><span style=\"font-weight: 400\">Ch\u00fang ta c\u00f3 th\u1ec3 th\u00eam c\u00e1c Item v\u00e0o t\u1eeb \u0111i\u1ec3n b\u1eb1ng ch\u1ee9c n\u0103ng Add. C\u00e1c Item c\u0169ng c\u00f3 th\u1ec3 \u0111\u01b0\u1ee3c th\u00eam b\u1eb1ng c\u00e1ch g\u00e1n m\u1ed9t gi\u00e1 tr\u1ecb m\u00e0 ch\u00fang ta s\u1ebd xem x\u00e9t trong ph\u1ea7n ti\u1ebfp theo.<\/span><\/p>\n<p><span style=\"font-weight: 400\">Ch\u00fang ta h\u00e3y xem x\u00e9t ch\u1ee9c n\u0103ng Add tr\u01b0\u1edbc. H\u00e0m Add c\u00f3 hai tham s\u1ed1: Key v\u00e0 Item. C\u1ea3 hai \u0111\u1ec1u l\u00e0 tham s\u1ed1 b\u1eaft bu\u1ed9c.<\/span><\/p>\n<p><span style=\"font-weight: 400\">Trong v\u00ed d\u1ee5 th\u00eam \u0111\u1ea7u ti\u00ean \u1edf tr\u00ean, ch\u00fang ta s\u1eed d\u1ee5ng t\u00ean tham s\u1ed1. B\u1ea1n kh\u00f4ng c\u1ea7n ph\u1ea3i l\u00e0m \u0111i\u1ec1u n\u00e0y m\u1eb7c d\u00f9 n\u00f3 c\u00f3 th\u1ec3 h\u1eefu \u00edch khi b\u1ea1n b\u1eaft \u0111\u1ea7u.<\/span><\/p>\n<pre><strong>dict.Add Key:=\"Orange\", Item:=45\r\ndict.Add \"Apple\", 66\r\ndict.Add \"12\/12\/2015\", \"John\"\r\ndict.Add 1, 45.56<\/strong><\/pre>\n<p><span style=\"font-weight: 400\">Key c\u00f3 th\u1ec3 l\u00e0 b\u1ea5t k\u1ef3 ki\u1ec3u d\u1eef li\u1ec7u n\u00e0o. Item c\u00f3 th\u1ec3 l\u00e0 b\u1ea5t k\u1ef3 ki\u1ec3u d\u1eef li\u1ec7u n\u00e0o, <\/span><span style=\"font-weight: 400\">m\u1ed9t \u0111\u1ed1i t\u01b0\u1ee3ng (Object), m\u1ea3ng (Array), b\u1ed9 s\u01b0u t\u1eadp (Collection) ho\u1eb7c th\u1eadm ch\u00ed l\u00e0 m\u1ed9t t\u1eeb \u0111i\u1ec3n (Dictionary)<\/span><span style=\"font-weight: 400\">. V\u00ec v\u1eady, b\u1ea1n c\u00f3 th\u1ec3 c\u00f3 m\u1ed9t T\u1eeb \u0111i\u1ec3n c\u1ee7a T\u1eeb \u0111i\u1ec3n, M\u1ea3ng v\u00e0 B\u1ed9 s\u01b0u t\u1eadp. Nh\u01b0ng h\u1ea7u h\u1ebft th\u1eddi gian n\u00f3 s\u1ebd l\u00e0 m\u1ed9t gi\u00e1 tr\u1ecb (ng\u00e0y, s\u1ed1 ho\u1eb7c v\u0103n b\u1ea3n).<\/span><\/p>\n<p><span style=\"font-weight: 400\">N\u1ebfu ch\u00fang ta th\u00eam m\u1ed9t Key \u0111\u00e3 t\u1ed3n t\u1ea1i trong T\u1eeb \u0111i\u1ec3n th\u00ec ch\u00fang ta s\u1ebd g\u1eb7p l\u1ed7i<\/span><\/p>\n<figure id=\"attachment_34182\" aria-describedby=\"caption-attachment-34182\" style=\"width: 367px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-34182\" src=\"http:\/\/blog.ezworkapp.com\/wp-content\/uploads\/2024\/12\/2-tu-dien-vba-trong-excel.png\" alt=\"2-T\u1eea \u0110I\u1ec2N VBA TRONG EXCEL\" width=\"367\" height=\"202\" title=\"2-tu-dien-vba-trong-excel\"><figcaption id=\"caption-attachment-34182\" class=\"wp-caption-text\">2-T\u1eea \u0110I\u1ec2N VBA TRONG EXCEL<\/figcaption><\/figure>\n<p><span style=\"font-weight: 400\">\u0110o\u1ea1n m\u00e3 sau s\u1ebd \u0111\u01b0a ra l\u1ed7i n\u00e0y<\/span><\/p>\n<pre><strong>dict.Add Key:=\"Orange\", Item:=45\r\n\r\n' This line gives an error as key exists already\r\ndict.Add Key:=\"Orange\", Item:=75<\/strong><\/pre>\n<h3><span class=\"ez-toc-section\" id=\"Chi_dinh_mot_gia_tri\"><\/span><b>Ch\u1ec9 \u0111\u1ecbnh m\u1ed9t gi\u00e1 tr\u1ecb<\/b><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<table>\n<tbody>\n<tr>\n<td><span style=\"font-weight: 400\">Ho\u1ea1t \u0111\u1ed9ng<\/span><\/td>\n<td><span style=\"font-weight: 400\">\u0110\u1ecbnh d\u1ea1ng<\/span><\/td>\n<td><span style=\"font-weight: 400\">V\u00ed d\u1ee5<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">G\u00e1n gi\u00e1 tr\u1ecb cho m\u1ed9t key trong Dictionary (T\u1eeb \u0111i\u1ec3n)<\/span><\/td>\n<td><span style=\"font-weight: 400\">Dictionary(Key) = Item<\/span><\/td>\n<td><span style=\"font-weight: 400\">dict(\u201cOranges\u201d) = 60<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><span style=\"font-weight: 400\">Ch\u00fang ta c\u00f3 th\u1ec3 thay \u0111\u1ed5i gi\u00e1 tr\u1ecb c\u1ee7a kh\u00f3a b\u1eb1ng \u0111o\u1ea1n m\u00e3 sau<\/span><\/p>\n<pre><strong>dict(\"Orange\") = 75<\/strong><\/pre>\n<p><span style=\"font-weight: 400\">G\u00e1n gi\u00e1 tr\u1ecb cho Key theo c\u00e1ch n\u00e0y c\u00f3 m\u1ed9t t\u00ednh n\u0103ng b\u1ed5 sung. N\u1ebfu Key kh\u00f4ng t\u1ed3n t\u1ea1i, n\u00f3 s\u1ebd t\u1ef1 \u0111\u1ed9ng th\u00eam Key v\u00e0 Item t\u1eeb \u0111i\u1ec3n. \u0110i\u1ec1u n\u00e0y s\u1ebd h\u1eefu \u00edch khi b\u1ea1n c\u00f3 m\u1ed9t danh s\u00e1ch c\u00e1c m\u1ee5c \u0111\u00e3 \u0111\u01b0\u1ee3c s\u1eafp x\u1ebfp v\u00e0 ch\u1ec9 mu\u1ed1n m\u1ee5c nh\u1eadp cu\u1ed1i c\u00f9ng cho m\u1ed7i m\u1ee5c.<\/span><\/p>\n<pre><strong>' Adds Orange to the dictionary \r\ndict(\"Orange\") = 45 \r\n\r\n' Changes the value of Orange to 100\r\ndict(\"Orange\") = 100<\/strong><\/pre>\n<p><span style=\"font-weight: 400\">\u0110\u1eebng qu\u00ean r\u1eb1ng b\u1ea1n c\u00f3 th\u1ec3 t\u1ea3i xu\u1ed1ng t\u1ea5t c\u1ea3 m\u00e3 VBA \u0111\u01b0\u1ee3c s\u1eed d\u1ee5ng trong b\u00e0i \u0111\u0103ng n\u00e0y t\u1eeb \u0111\u1ea7u ho\u1eb7c cu\u1ed1i b\u00e0i \u0111\u0103ng.<\/span><\/p>\n<h3><span class=\"ez-toc-section\" id=\"Kiem_tra_Key_ton_tai\"><\/span><b>Ki\u1ec3m tra Key t\u1ed3n t\u1ea1i<\/b><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<table>\n<tbody>\n<tr>\n<td><span style=\"font-weight: 400\">Ch\u1ee9c n\u0103ng<\/span><\/td>\n<td><span style=\"font-weight: 400\">Paraments<\/span><\/td>\n<td><span style=\"font-weight: 400\">V\u00ed d\u1ee5<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">Exists<\/span><\/td>\n<td><span style=\"font-weight: 400\">Key<\/span><\/td>\n<td><span style=\"font-weight: 400\">If dict.Exists(\u201cApples\u201d) Then<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><span style=\"font-weight: 400\">Ch\u00fang ta c\u00f3 th\u1ec3 s\u1eed d\u1ee5ng h\u00e0m Exists \u0111\u1ec3 ki\u1ec3m tra xem Key c\u00f3 t\u1ed3n t\u1ea1i trong t\u1eeb \u0111i\u1ec3n hay kh\u00f4ng.<\/span><\/p>\n<pre><strong>' Checks for the key 'Orange' in the dictionary\r\nIf dict.Exists(\"Orange\") Then\r\n    MsgBox \"The number of oranges is \" &amp; dict(\"Orange\") \r\nElse\r\n    MsgBox \"There is no entry for Orange in the dictionary.\"\r\nEnd If<\/strong><\/pre>\n<h3><span class=\"ez-toc-section\" id=\"Luu_tru_nhieu_gia_tri_trong_Key\"><\/span><b>L\u01b0u tr\u1eef nhi\u1ec1u gi\u00e1 tr\u1ecb trong Key<\/b><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><span style=\"font-weight: 400\">H\u00e3y xem d\u1eef li\u1ec7u m\u1eabu b\u00ean d\u01b0\u1edbi. Ch\u00fang ta mu\u1ed1n l\u01b0u tr\u1eef <\/span><i><span style=\"font-weight: 400\">Amount<\/span><\/i> <span style=\"font-weight: 400\">\u00a0v\u00e0 Item cho m\u1ed7i <\/span><i><span style=\"font-weight: 400\">Customer ID<\/span><\/i><span style=\"font-weight: 400\">.<\/span><\/p>\n<p><span style=\"font-weight: 400\">T\u1eeb \u0111i\u1ec3n ch\u1ec9 l\u01b0u tr\u1eef m\u1ed9t gi\u00e1 tr\u1ecb v\u1eady ch\u00fang ta c\u00f3 th\u1ec3 l\u00e0m g\u00ec?<\/span><\/p>\n<p><span style=\"font-weight: 400\">Ch\u00fang ta c\u00f3 th\u1ec3 s\u1eed d\u1ee5ng m\u1ed9t m\u1ea3ng ho\u1eb7c t\u1eadp h\u1ee3p l\u00e0m gi\u00e1 tr\u1ecb nh\u01b0ng \u0111i\u1ec1u n\u00e0y l\u00e0 kh\u00f4ng c\u1ea7n thi\u1ebft. C\u00e1ch t\u1ed1t nh\u1ea5t \u0111\u1ec3 l\u00e0m \u0111i\u1ec1u \u0111\u00f3 l\u00e0 s\u1eed d\u1ee5ng Class Module.<\/span><\/p>\n<p><span style=\"font-weight: 400\">\u0110o\u1ea1n m\u00e3 sau \u0111\u00e2y cho th\u1ea5y c\u00e1ch ch\u00fang ta c\u00f3 th\u1ec3 l\u00e0m \u0111i\u1ec1u n\u00e0y.<\/span><\/p>\n<pre><strong>' clsCustomer Class Module Code\r\nPublic CustomerID As String\r\nPublic Amount As Long\r\nPublic Items As Long\r\n<\/strong><\/pre>\n<pre><strong>' Create a new clsCustomer object\r\nSet oCust = New clsCustomer\r\n\r\n' Set the values\r\noCust.CustomerID = rg.Cells(i, 1).Value\r\noCust.Amount = rg.Cells(i, 2).Value\r\noCust.Items = rg.Cells(i, 3).Value\r\n\r\n' Add the new clsCustomer object to the dictionary\r\ndict.Add oCust.CustomerID, oCust\r\n<\/strong><\/pre>\n<p><span style=\"font-weight: 400\">B\u1ea1n c\u00f3 th\u1ec3 th\u1ea5y r\u1eb1ng b\u1eb1ng c\u00e1ch s\u1eed d\u1ee5ng M\u00f4-\u0111un L\u1edbp, ch\u00fang ta c\u00f3 th\u1ec3 l\u01b0u tr\u1eef bao nhi\u00eau tr\u01b0\u1eddng t\u00f9y th\u00edch. V\u00ed d\u1ee5 2 v\u00e0 3 \u1edf cu\u1ed1i b\u00e0i \u0111\u0103ng cho th\u1ea5y c\u00e1ch s\u1eed d\u1ee5ng m\u00f4-\u0111un l\u1edbp v\u1edbi T\u1eeb \u0111i\u1ec3n.<\/span><\/p>\n<h3><span class=\"ez-toc-section\" id=\"Cac_chuc_nang_huu_ich_khac\"><\/span><b>C\u00e1c ch\u1ee9c n\u0103ng h\u1eefu \u00edch kh\u00e1c<\/b><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<table>\n<tbody>\n<tr>\n<td><span style=\"font-weight: 400\">Ch\u1ee9c n\u0103ng\u00a0<\/span><\/td>\n<td><span style=\"font-weight: 400\">Paraments<\/span><\/td>\n<td><span style=\"font-weight: 400\">V\u00ed d\u1ee5<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">Count<\/span><\/td>\n<td><span style=\"font-weight: 400\">N\/A<\/span><\/td>\n<td><span style=\"font-weight: 400\">dict.Count<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">Remove<\/span><\/td>\n<td><span style=\"font-weight: 400\">Key<\/span><\/td>\n<td><span style=\"font-weight: 400\">dict.Remove \u201cApples\u201d<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">Remove all<\/span><\/td>\n<td><span style=\"font-weight: 400\">N\/A<\/span><\/td>\n<td><span style=\"font-weight: 400\">dict.RemoveAll<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><span style=\"font-weight: 400\">Ba h\u00e0m trong b\u1ea3ng tr\u00ean th\u1ef1c hi\u1ec7n nh\u01b0 sau:<\/span><\/p>\n<ol>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">Count \u2013 tr\u1ea3 v\u1ec1 s\u1ed1 l\u01b0\u1ee3ng m\u1ee5c trong T\u1eeb \u0111i\u1ec3n.\u00a0\u00a0<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">Remove \u2013 lo\u1ea1i b\u1ecf m\u1ed9t Key nh\u1ea5t \u0111\u1ecbnh kh\u1ecfi T\u1eeb \u0111i\u1ec3n.\u00a0\u00a0<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">RemoveAll \u2013 x\u00f3a t\u1ea5t c\u1ea3 c\u00e1c m\u1ee5c kh\u1ecfi T\u1eeb \u0111i\u1ec3n<\/span><\/li>\n<\/ol>\n<p><span style=\"font-weight: 400\">Ph\u1ea7n ph\u1ee5 sau \u0111\u00e2y cho th\u1ea5y m\u1ed9t v\u00ed d\u1ee5 v\u1ec1 c\u00e1ch b\u1ea1n s\u1ebd s\u1eed d\u1ee5ng c\u00e1c h\u00e0m n\u00e0y.<\/span><\/p>\n<pre><strong>' https:\/\/excelmacromastery.com\/\r\nSub AddRemoveCount()\r\n\r\n    Dim dict As New Scripting.Dictionary\r\n\r\n    ' Add some items\r\n    dict.Add \"Orange\", 55\r\n    dict.Add \"Peach\", 55\r\n    dict.Add \"Plum\", 55\r\n    Debug.Print \"The number of items is \" &amp; dict.Count\r\n    \r\n    ' Remove one item\r\n    dict.Remove \"Orange\"\r\n    Debug.Print \"The number of items is \" &amp; dict.Count\r\n    \r\n    ' Remove all items\r\n    dict.RemoveAll\r\n    Debug.Print \"The number of items is \" &amp; dict.Count\r\n\r\nEnd Sub<\/strong><\/pre>\n<p><span style=\"font-weight: 400\">H\u00e3y nh\u1edb r\u1eb1ng b\u1ea1n c\u00f3 th\u1ec3 t\u1ea3i xu\u1ed1ng t\u1ea5t c\u1ea3 c\u00e1c v\u00ed d\u1ee5 m\u00e3 t\u1eeb b\u00e0i \u0111\u0103ng. Ch\u1ec9 c\u1ea7n chuy\u1ec3n \u0111\u1ebfn ph\u1ea7n <\/span><span style=\"font-weight: 400\">t\u1ea3i xu\u1ed1ng<\/span><span style=\"font-weight: 400\"> \u1edf tr\u00ean c\u00f9ng.<\/span><\/p>\n<h3><span class=\"ez-toc-section\" id=\"Key_va_chu_hoa_chu_thuong\"><\/span><b>Key v\u00e0 ch\u1eef hoa ch\u1eef th\u01b0\u1eddng<\/b><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><span style=\"font-weight: 400\">M\u1ed9t s\u1ed1 h\u00e0m chu\u1ed7i trong VBA c\u00f3 <\/span><span style=\"font-weight: 400\">vbCompareMethod<\/span><span style=\"font-weight: 400\">. \u0110i\u1ec1u n\u00e0y \u0111\u01b0\u1ee3c s\u1eed d\u1ee5ng cho c\u00e1c h\u00e0m so s\u00e1nh c\u00e1c chu\u1ed7i. N\u00f3 \u0111\u01b0\u1ee3c s\u1eed d\u1ee5ng \u0111\u1ec3 x\u00e1c \u0111\u1ecbnh xem tr\u01b0\u1eddng h\u1ee3p c\u1ee7a c\u00e1c ch\u1eef c\u00e1i c\u00f3 quan tr\u1ecdng hay kh\u00f4ng.<\/span><\/p>\n<p><span style=\"font-weight: 400\">T\u1eeb \u0111i\u1ec3n s\u1eed d\u1ee5ng m\u1ed9t ph\u01b0\u01a1ng ph\u00e1p t\u01b0\u01a1ng t\u1ef1. Thu\u1ed9c t\u00ednh <\/span><b>CompareMode <\/b><span style=\"font-weight: 400\">c\u1ee7a t\u1eeb \u0111i\u1ec3n \u0111\u01b0\u1ee3c s\u1eed d\u1ee5ng \u0111\u1ec3 x\u00e1c \u0111\u1ecbnh xem tr\u01b0\u1eddng h\u1ee3p c\u1ee7a c\u00e1c key c\u00f3 quan tr\u1ecdng hay kh\u00f4ng.\u00a0 C\u00e1c c\u00e0i \u0111\u1eb7t l\u00e0:<\/span><\/p>\n<p><b>vbTextCompare<\/b><span style=\"font-weight: 400\">: Ch\u1eef hoa v\u00e0 ch\u1eef th\u01b0\u1eddng \u0111\u01b0\u1ee3c coi l\u00e0 gi\u1ed1ng nhau.\u00a0\u00a0<\/span><\/p>\n<p><b>vbBinaryCompare<\/b><span style=\"font-weight: 400\">: Ch\u1eef hoa v\u00e0 ch\u1eef th\u01b0\u1eddng \u0111\u01b0\u1ee3c coi l\u00e0 kh\u00e1c nhau. \u0110\u00e2y l\u00e0 m\u1eb7c \u0111\u1ecbnh.<\/span><\/p>\n<p><span style=\"font-weight: 400\">V\u1edbi T\u1eeb \u0111i\u1ec3n, ch\u00fang ta c\u00f3 th\u1ec3 s\u1eed d\u1ee5ng c\u00e1c c\u00e0i \u0111\u1eb7t n\u00e0y \u0111\u1ec3 x\u00e1c \u0111\u1ecbnh xem tr\u01b0\u1eddng h\u1ee3p c\u1ee7a c\u00e1c key c\u00f3 quan tr\u1ecdng hay kh\u00f4ng.<\/span><\/p>\n<pre><strong>' https:\/\/excelmacromastery.com\/\r\nSub CaseMatters()\r\n    \r\n    Dim dict As New Scripting.Dictionary\r\n    dict.CompareMode = vbBinaryCompare\r\n    dict.Add \"Orange\", 1\r\n    \r\n    ' Prints False because it considers Orange and ORANGE different \r\n    Debug.Print dict.Exists(\"ORANGE\")    \r\n    \r\n    Set dict = Nothing\r\n\r\nEnd Sub<\/strong><\/pre>\n<p><span style=\"font-weight: 400\">L\u1ea7n n\u00e0y ch\u00fang ta s\u1eed d\u1ee5ng vbTextCompare c\u00f3 ngh\u0129a l\u00e0 tr\u01b0\u1eddng h\u1ee3p kh\u00f4ng th\u00e0nh v\u1ea5n \u0111\u1ec1:<\/span><\/p>\n<pre><strong>' https:\/\/excelmacromastery.com\/\r\nSub CaseMattersNot()\r\n    \r\n    Dim dict As New Scripting.Dictionary\r\n    dict.CompareMode = vbTextCompare\r\n    dict.Add \"Orange\", 1\r\n    \r\n    ' Prints true because it considers Orange and ORANGE the same\r\n    Debug.Print dict.Exists(\"ORANGE\")    \r\n    \r\n    Set dict = Nothing\r\n\r\nEnd Sub<\/strong><\/pre>\n<p><b>L\u01b0u \u00fd: <\/b><span style=\"font-weight: 400\">T\u1eeb \u0111i\u1ec3n ph\u1ea3i tr\u1ed1ng khi b\u1ea1n s\u1eed d\u1ee5ng thu\u1ed9c t\u00ednh <\/span><b>CompareMode<\/b><span style=\"font-weight: 400\">, n\u1ebfu kh\u00f4ng b\u1ea1n s\u1ebd g\u1eb7p l\u1ed7i: \u201cInvalid procedure call or argument\u201d.<\/span><\/p>\n<h2><span class=\"ez-toc-section\" id=\"Nhung_dieu_can_chu_y\"><\/span><b>Nh\u1eefng \u0111i\u1ec1u c\u1ea7n ch\u00fa \u00fd<\/b><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><b>vbBinaryCompare <\/b><span style=\"font-weight: 400\">(tr\u01b0\u1eddng h\u1ee3p quan tr\u1ecdng) l\u00e0 m\u1eb7c \u0111\u1ecbnh v\u00e0 \u0111i\u1ec1u n\u00e0y c\u00f3 th\u1ec3 d\u1eabn \u0111\u1ebfn c\u00e1c l\u1ed7i nh\u1ecf. V\u00ed d\u1ee5: h\u00e3y t\u01b0\u1edfng t\u01b0\u1ee3ng b\u1ea1n c\u00f3 d\u1eef li\u1ec7u sau trong c\u00e1c \u00f4 A1 \u0111\u1ebfn B2.<\/span><\/p>\n<p><span style=\"font-weight: 400\">Orange, 5<\/span><\/p>\n<p><span style=\"font-weight: 400\">orange, 12<\/span><\/p>\n<p><span style=\"font-weight: 400\">\u0110o\u1ea1n m\u00e3 sau s\u1ebd t\u1ea1o hai kh\u00f3a \u2013 b\u1eadt cho \u201cOrange\u201d v\u00e0 m\u1ed9t cho \u201corange\u201d. \u0110i\u1ec1u n\u00e0y tinh t\u1ebf v\u00ec s\u1ef1 kh\u00e1c bi\u1ec7t duy nh\u1ea5t l\u00e0 tr\u01b0\u1eddng h\u1ee3p c\u1ee7a ch\u1eef c\u00e1i \u0111\u1ea7u ti\u00ean.<\/span><\/p>\n<pre><strong>' https:\/\/excelmacromastery.com\/\r\nSub DiffCase()\r\n\r\n    Dim dict As New Scripting.Dictionary\r\n    \r\n    dict.Add Key:=(Range(\"A1\")), Item:=Range(\"B1\")\r\n    dict.Add Key:=(Range(\"A2\")), Item:=Range(\"B2\")\r\n\r\nEnd Sub<\/strong><\/pre>\n<p><span style=\"font-weight: 400\">N\u1ebfu b\u1ea1n s\u1eed d\u1ee5ng <strong>vbTextCompare<\/strong> cho c\u00f9ng m\u1ed9t d\u1eef li\u1ec7u, b\u1ea1n s\u1ebd g\u1eb7p l\u1ed7i khi c\u1ed1 g\u1eafng th\u00eam key th\u1ee9 hai v\u00ec n\u00f3 coi \u201cOrange\u201d v\u00e0 \u201corange\u201d gi\u1ed1ng nhau.<\/span><\/p>\n<pre><strong>' https:\/\/excelmacromastery.com\/\r\nSub UseTextcompare()\r\n\r\n    Dim dict As New Scripting.Dictionary\r\n    dict.CompareMode = vbTextCompare\r\n    \r\n    dict.Add Key:=(Range(\"A1\")), Item:=Range(\"B1\")\r\n    ' This line will give an error as your are trying to add the same key\r\n    dict.Add Key:=(Range(\"A2\")), Item:=Range(\"B2\")\r\n\r\nEnd Sub<\/strong><\/pre>\n<p><span style=\"font-weight: 400\">N\u1ebfu b\u1ea1n s\u1eed d\u1ee5ng ph\u01b0\u01a1ng ph\u00e1p g\u00e1n th\u00ec n\u00f3 kh\u00f4ng t\u00ednh \u0111\u1ebfn <\/span><b>CompareMode<\/b><span style=\"font-weight: 400\"> . V\u00ec v\u1eady, \u0111o\u1ea1n m\u00e3 sau v\u1eabn s\u1ebd th\u00eam hai key m\u1eb7c d\u00f9 CompareMode \u0111\u01b0\u1ee3c \u0111\u1eb7t th\u00e0nh<strong> vbTextCompare<\/strong>.<\/span><\/p>\n<pre><strong>' https:\/\/excelmacromastery.com\/\r\nSub Assign()\r\n    \r\n    Dim dict As New Scripting.Dictionary\r\n    dict.CompareMode = vbTextCompare\r\n    \r\n    ' Adds two keys\r\n    dict(Range(\"A1\")) = Range(\"B1\")\r\n    dict(Range(\"A2\")) = Range(\"B2\")\r\n    \r\n    ' Prints 2\r\n    Debug.Print dict.Count\r\n    \r\nEnd Sub<\/strong><\/pre>\n<h3><span class=\"ez-toc-section\" id=\"Doc_qua_tu_dien\"><\/span><b>\u0110\u1ecdc qua t\u1eeb \u0111i\u1ec3n<\/b><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><span style=\"font-weight: 400\">Ch\u00fang ta c\u00f3 th\u1ec3 \u0111\u1ecdc qua t\u1ea5t c\u1ea3 c\u00e1c m\u1ee5c trong T\u1eeb \u0111i\u1ec3n. Ch\u00fang ta c\u00f3 th\u1ec3 xem qua c\u00e1c key b\u1eb1ng c\u00e1ch s\u1eed d\u1ee5ng v\u00f2ng l\u1eb7p For Each. Sau \u0111\u00f3, ch\u00fang ta s\u1eed d\u1ee5ng key hi\u1ec7n t\u1ea1i \u0111\u1ec3 truy c\u1eadp m\u1ed9t m\u1ee5c.<\/span><\/p>\n<pre><strong>Dim k As Variant\r\nFor Each k In dict.Keys\r\n    ' Print key and value\r\n    Debug.Print k, dict(k)\r\nNext<\/strong><\/pre>\n<p><span style=\"font-weight: 400\">Ch\u00fang ta c\u0169ng c\u00f3 th\u1ec3 l\u1eb7p l\u1ea1i c\u00e1c key m\u1eb7c d\u00f9 t\u00ednh n\u0103ng n\u00e0y ch\u1ec9 ho\u1ea1t \u0111\u1ed9ng v\u1edbi Early Binding (B\u1ea3n c\u1eadp nh\u1eadt th\u00e1ng 2 n\u0103m 2020: Trong Office 365, t\u00ednh n\u0103ng n\u00e0y hi\u1ec7n ho\u1ea1t \u0111\u1ed9ng v\u1edbi c\u1ea3 hai phi\u00ean b\u1ea3n):<\/span><\/p>\n<pre><strong>Dim i As Long\r\nFor i = 0 To dict.Count - 1\r\n    Debug.Print dict.Keys(i), dict.Items(i)\r\nNext i<\/strong><\/pre>\n<p><span style=\"font-weight: 400\">Ph\u01b0\u01a1ng ph\u00e1p n\u00e0y ho\u1ea1t \u0111\u1ed9ng v\u1edbi c\u1ea3 r\u00e0ng bu\u1ed9c Early v\u00e0 Late binding:<\/span><\/p>\n<pre><strong>Dim i As Long\r\nFor i = 0 To dict.Count - 1\r\n   Debug.Print dict.Keys()(i), dict.Items()(i)\r\nNext i<\/strong><\/pre>\n<p><b>S\u1eafp x\u1ebfp t\u1eeb \u0111i\u1ec3n<\/b><\/p>\n<p><span style=\"font-weight: 400\">\u0110\u00f4i khi b\u1ea1n c\u00f3 th\u1ec3 mu\u1ed1n s\u1eafp x\u1ebfp T\u1eeb \u0111i\u1ec3n theo kew ho\u1eb7c theo gi\u00e1 tr\u1ecb.<\/span><\/p>\n<p><span style=\"font-weight: 400\">T\u1eeb \u0111i\u1ec3n kh\u00f4ng c\u00f3 ch\u1ee9c n\u0103ng s\u1eafp x\u1ebfp n\u00ean b\u1ea1n ph\u1ea3i t\u1ef1 t\u1ea1o. T\u00f4i \u0111\u00e3 vi\u1ebft hai h\u00e0m s\u1eafp x\u1ebfp \u2013 m\u1ed9t \u0111\u1ec3 s\u1eafp x\u1ebfp theo key v\u00e0 m\u1ed9t \u0111\u1ec3 s\u1eafp x\u1ebfp theo gi\u00e1 tr\u1ecb.<\/span><\/p>\n<h3><span class=\"ez-toc-section\" id=\"Sap_xep_theo_key\"><\/span><b>S\u1eafp x\u1ebfp theo key<\/b><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><span style=\"font-weight: 400\">\u0110\u1ec3 s\u1eafp x\u1ebfp t\u1eeb \u0111i\u1ec3n theo key, b\u1ea1n c\u00f3 th\u1ec3 s\u1eed d\u1ee5ng ch\u1ee9c n\u0103ng SortDictionaryByKey b\u00ean d\u01b0\u1edbi:<\/span><\/p>\n<p><b>Public<\/b> <b>Function<\/b><span style=\"font-weight: 400\"> SortDictionaryByKey(dict <\/span><b>As<\/b> <b>Object<\/b><span style=\"font-weight: 400\"> _<\/span><\/p>\n<p><span style=\"font-weight: 400\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0, Optional sortorder <\/span><b>As<\/b><span style=\"font-weight: 400\"> XlSortOrder = xlAscending) <\/span><b>As<\/b> <b>Object<\/b><\/p>\n<p><span style=\"font-weight: 400\">\u00a0\u00a0\u00a0\u00a0<\/span><b>Dim<\/b><span style=\"font-weight: 400\"> arrList <\/span><b>As<\/b> <b>Object<\/b><\/p>\n<p><span style=\"font-weight: 400\">\u00a0\u00a0\u00a0\u00a0<\/span><b>Set<\/b><span style=\"font-weight: 400\"> arrList = CreateObject(<\/span><span style=\"font-weight: 400\">\u201cSystem.Collections.ArrayList\u201d<\/span><span style=\"font-weight: 400\">)<\/span><\/p>\n<p><span style=\"font-weight: 400\">\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"font-weight: 400\">\u2018 Put keys in an ArrayList<\/span><\/p>\n<p><span style=\"font-weight: 400\">\u00a0\u00a0\u00a0\u00a0<\/span><b>Dim<\/b><span style=\"font-weight: 400\"> key <\/span><b>As<\/b> <b>Variant<\/b><span style=\"font-weight: 400\">, coll <\/span><b>As<\/b> <b>New<\/b><span style=\"font-weight: 400\"> Collection<\/span><\/p>\n<p><span style=\"font-weight: 400\">\u00a0\u00a0\u00a0\u00a0<\/span><b>For<\/b> <b>Each<\/b><span style=\"font-weight: 400\"> key <\/span><b>In<\/b><span style=\"font-weight: 400\"> dict<\/span><\/p>\n<p><span style=\"font-weight: 400\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0arrList.Add key<\/span><\/p>\n<p><span style=\"font-weight: 400\">\u00a0\u00a0\u00a0\u00a0<\/span><b>Next<\/b><span style=\"font-weight: 400\"> key<\/span><\/p>\n<p><span style=\"font-weight: 400\">\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"font-weight: 400\">\u2018 Sort the keys<\/span><\/p>\n<p><span style=\"font-weight: 400\">\u00a0\u00a0\u00a0\u00a0arrList.Sort<\/span><\/p>\n<p><span style=\"font-weight: 400\">\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"font-weight: 400\">\u2018 For descending order, reverse<\/span><\/p>\n<p><span style=\"font-weight: 400\">\u00a0\u00a0\u00a0\u00a0<\/span><b>If<\/b><span style=\"font-weight: 400\"> sortorder = xlDescending <\/span><b>Then<\/b><\/p>\n<p><span style=\"font-weight: 400\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0arrList.Reverse<\/span><\/p>\n<p><span style=\"font-weight: 400\">\u00a0\u00a0\u00a0\u00a0<\/span><b>End<\/b> <b>If<\/b><\/p>\n<p><span style=\"font-weight: 400\">\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"font-weight: 400\">\u2018 Create new dictionary<\/span><\/p>\n<p><span style=\"font-weight: 400\">\u00a0\u00a0\u00a0\u00a0<\/span><b>Dim<\/b><span style=\"font-weight: 400\"> dictNew <\/span><b>As<\/b> <b>Object<\/b><\/p>\n<p><span style=\"font-weight: 400\">\u00a0\u00a0\u00a0\u00a0<\/span><b>Set<\/b><span style=\"font-weight: 400\"> dictNew = CreateObject(<\/span><span style=\"font-weight: 400\">\u201cScripting.Dictionary\u201d<\/span><span style=\"font-weight: 400\">)<\/span><\/p>\n<p><span style=\"font-weight: 400\">\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"font-weight: 400\">\u2018 Read through the sorted keys and add to new dictionary<\/span><\/p>\n<p><span style=\"font-weight: 400\">\u00a0\u00a0\u00a0\u00a0<\/span><b>For<\/b> <b>Each<\/b><span style=\"font-weight: 400\"> key <\/span><b>In<\/b><span style=\"font-weight: 400\"> arrList<\/span><\/p>\n<p><span style=\"font-weight: 400\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0dictNew.Add key, dict(key)<\/span><\/p>\n<p><span style=\"font-weight: 400\">\u00a0\u00a0\u00a0\u00a0<\/span><b>Next<\/b><span style=\"font-weight: 400\"> key<\/span><\/p>\n<p><span style=\"font-weight: 400\">\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"font-weight: 400\">\u2018 Clean up<\/span><\/p>\n<p><span style=\"font-weight: 400\">\u00a0\u00a0\u00a0\u00a0<\/span><b>Set<\/b><span style=\"font-weight: 400\"> arrList = <\/span><b>Nothing<\/b><\/p>\n<p><span style=\"font-weight: 400\">\u00a0\u00a0\u00a0\u00a0<\/span><b>Set<\/b><span style=\"font-weight: 400\"> dict = <\/span><b>Nothing<\/b><\/p>\n<p><span style=\"font-weight: 400\">\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"font-weight: 400\">\u2018 Return the new dictionary<\/span><\/p>\n<p><span style=\"font-weight: 400\">\u00a0\u00a0\u00a0\u00a0<\/span><b>Set<\/b><span style=\"font-weight: 400\"> SortDictionaryByKey = dictNew<\/span><\/p>\n<p><b>End<\/b> <b>Function<\/b><\/p>\n<p><span style=\"font-weight: 400\">\u0110o\u1ea1n m\u00e3 d\u01b0\u1edbi \u0111\u00e2y cho b\u1ea1n th\u1ea5y c\u00e1ch s\u1eed d\u1ee5ng <\/span><b>SortDictionaryByKey<\/b><\/p>\n<pre><strong>' https:\/\/excelmacromastery.com\/\r\nSub TestSortByKey()\r\n\r\n    Dim dict As Object\r\n    Set dict = CreateObject(\"Scripting.Dictionary\")\r\n    \r\n    dict.Add \"Plum\", 99\r\n    dict.Add \"Apple\", 987\r\n    dict.Add \"Pear\", 234\r\n    dict.Add \"Banana\", 560\r\n    dict.Add \"Orange\", 34\r\n    \r\n    PrintDictionary \"Original\", dict\r\n    \r\n    ' Sort Ascending\r\n    Set dict = SortDictionaryByKey(dict)\r\n    PrintDictionary \"Key Ascending\", dict\r\n    \r\n    ' Sort Descending\r\n    Set dict = SortDictionaryByKey(dict, xlDescending)\r\n    PrintDictionary \"Key Descending\", dict\r\n    \r\nEnd Sub\r\n\r\nPublic Sub PrintDictionary(ByVal sText As String, dict As Object)\r\n    \r\n    Debug.Print vbCrLf &amp; sText &amp; vbCrLf &amp; String(Len(sText), \"=\")\r\n    \r\n    Dim key As Variant\r\n    For Each key In dict.keys\r\n        Debug.Print key, dict(key)\r\n    Next\r\nEnd Sub<\/strong><\/pre>\n<h3><span class=\"ez-toc-section\" id=\"Sap_xep_bang_gia_tri\"><\/span><b>S\u1eafp x\u1ebfp b\u1eb1ng gi\u00e1 tr\u1ecb<\/b><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><span style=\"font-weight: 400\">\u0110\u1ec3 s\u1eafp x\u1ebfp t\u1eeb \u0111i\u1ec3n theo c\u00e1c gi\u00e1 tr\u1ecb, b\u1ea1n c\u00f3 th\u1ec3 s\u1eed d\u1ee5ng h\u00e0m SortDictionaryByValue b\u00ean d\u01b0\u1edbi.<\/span><\/p>\n<p><span style=\"font-weight: 400\">\u2018 https:\/\/excelmacromastery.com\/<\/span><\/p>\n<p><b>Public<\/b> <b>Function<\/b><span style=\"font-weight: 400\"> SortDictionaryByValue(dict <\/span><b>As<\/b> <b>Object<\/b><span style=\"font-weight: 400\"> _<\/span><\/p>\n<p><span style=\"font-weight: 400\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0, Optional sortorder <\/span><b>As<\/b><span style=\"font-weight: 400\"> XlSortOrder = xlAscending) <\/span><b>As<\/b> <b>Object<\/b><\/p>\n<p><span style=\"font-weight: 400\">\u00a0\u00a0\u00a0\u00a0<\/span><b>On<\/b><span style=\"font-weight: 400\"> Error GoTo eh<\/span><\/p>\n<p><span style=\"font-weight: 400\">\u00a0\u00a0\u00a0\u00a0<\/span><b>Dim<\/b><span style=\"font-weight: 400\"> arrayList <\/span><b>As<\/b> <b>Object<\/b><\/p>\n<p><span style=\"font-weight: 400\">\u00a0\u00a0\u00a0\u00a0<\/span><b>Set<\/b><span style=\"font-weight: 400\"> arrayList = CreateObject(<\/span><span style=\"font-weight: 400\">\u201cSystem.Collections.ArrayList\u201d<\/span><span style=\"font-weight: 400\">)<\/span><\/p>\n<p><span style=\"font-weight: 400\">\u00a0\u00a0\u00a0\u00a0<\/span><b>Dim<\/b><span style=\"font-weight: 400\"> dictTemp <\/span><b>As<\/b> <b>Object<\/b><\/p>\n<p><span style=\"font-weight: 400\">\u00a0\u00a0\u00a0\u00a0<\/span><b>Set<\/b><span style=\"font-weight: 400\"> dictTemp = CreateObject(<\/span><span style=\"font-weight: 400\">\u201cScripting.Dictionary\u201d<\/span><span style=\"font-weight: 400\">)<\/span><\/p>\n<p><span style=\"font-weight: 400\">\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"font-weight: 400\">\u2018 Put values in ArrayList and sort<\/span><\/p>\n<p><span style=\"font-weight: 400\">\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"font-weight: 400\">\u2018 Store values in tempDict with their keys as a collection<\/span><\/p>\n<p><span style=\"font-weight: 400\">\u00a0\u00a0\u00a0\u00a0<\/span><b>Dim<\/b><span style=\"font-weight: 400\"> key <\/span><b>As<\/b> <b>Variant<\/b><span style=\"font-weight: 400\">, value <\/span><b>As<\/b> <b>Variant<\/b><span style=\"font-weight: 400\">, coll <\/span><b>As<\/b><span style=\"font-weight: 400\"> Collection<\/span><\/p>\n<p><span style=\"font-weight: 400\">\u00a0\u00a0\u00a0\u00a0<\/span><b>For<\/b> <b>Each<\/b><span style=\"font-weight: 400\"> key <\/span><b>In<\/b><span style=\"font-weight: 400\"> dict<\/span><\/p>\n<p><span style=\"font-weight: 400\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0value = dict(key)<\/span><\/p>\n<p><span style=\"font-weight: 400\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"font-weight: 400\">\u2018 if the value doesn\u2019t exist in dict then add<\/span><\/p>\n<p><span style=\"font-weight: 400\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/span><b>If<\/b><span style=\"font-weight: 400\"> dictTemp.exists(value) = <\/span><b>False<\/b> <b>Then<\/b><\/p>\n<p><span style=\"font-weight: 400\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"font-weight: 400\">\u2018 create collection to hold keys<\/span><\/p>\n<p><span style=\"font-weight: 400\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"font-weight: 400\">\u2018 \u2013 needed for duplicate values<\/span><\/p>\n<p><span style=\"font-weight: 400\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/span><b>Set<\/b><span style=\"font-weight: 400\"> coll = <\/span><b>New<\/b><span style=\"font-weight: 400\"> Collection<\/span><\/p>\n<p><span style=\"font-weight: 400\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0dictTemp.Add value, coll<\/span><\/p>\n<p><span style=\"font-weight: 400\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"font-weight: 400\">\u2018 Add the value<\/span><\/p>\n<p><span style=\"font-weight: 400\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0arrayList.Add value<\/span><\/p>\n<p><span style=\"font-weight: 400\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/span><b>End<\/b> <b>If<\/b><\/p>\n<p><span style=\"font-weight: 400\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"font-weight: 400\">\u2018 Add the current key to the collection<\/span><\/p>\n<p><span style=\"font-weight: 400\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0dictTemp(value).Add key<\/span><\/p>\n<p><span style=\"font-weight: 400\">\u00a0\u00a0\u00a0\u00a0<\/span><b>Next<\/b><span style=\"font-weight: 400\"> key<\/span><\/p>\n<p><span style=\"font-weight: 400\">\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"font-weight: 400\">\u2018 Sort the value<\/span><\/p>\n<p><span style=\"font-weight: 400\">\u00a0\u00a0\u00a0\u00a0arrayList.Sort<\/span><\/p>\n<p><span style=\"font-weight: 400\">\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"font-weight: 400\">\u2018 Reverse if descending<\/span><\/p>\n<p><span style=\"font-weight: 400\">\u00a0\u00a0\u00a0\u00a0<\/span><b>If<\/b><span style=\"font-weight: 400\"> sortorder = xlDescending <\/span><b>Then<\/b><\/p>\n<p><span style=\"font-weight: 400\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0arrayList.Reverse<\/span><\/p>\n<p><span style=\"font-weight: 400\">\u00a0\u00a0\u00a0\u00a0<\/span><b>End<\/b> <b>If<\/b><\/p>\n<p><span style=\"font-weight: 400\">\u00a0\u00a0\u00a0\u00a0dict.RemoveAll<\/span><\/p>\n<p><span style=\"font-weight: 400\">\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"font-weight: 400\">\u2018 Read through the ArrayList and add the values and corresponding<\/span><\/p>\n<p><span style=\"font-weight: 400\">\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"font-weight: 400\">\u2018 keys from the dictTemp<\/span><\/p>\n<p><span style=\"font-weight: 400\">\u00a0\u00a0\u00a0\u00a0<\/span><b>Dim<\/b><span style=\"font-weight: 400\"> item <\/span><b>As<\/b> <b>Variant<\/b><\/p>\n<p><span style=\"font-weight: 400\">\u00a0\u00a0\u00a0\u00a0<\/span><b>For<\/b> <b>Each<\/b><span style=\"font-weight: 400\"> value <\/span><b>In<\/b><span style=\"font-weight: 400\"> arrayList<\/span><\/p>\n<p><span style=\"font-weight: 400\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/span><b>Set<\/b><span style=\"font-weight: 400\"> coll = dictTemp(value)<\/span><\/p>\n<p><span style=\"font-weight: 400\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/span><b>For<\/b> <b>Each<\/b><span style=\"font-weight: 400\"> item <\/span><b>In<\/b><span style=\"font-weight: 400\"> coll<\/span><\/p>\n<p><span style=\"font-weight: 400\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0dict.Add item, value<\/span><\/p>\n<p><span style=\"font-weight: 400\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/span><b>Next<\/b><span style=\"font-weight: 400\"> item<\/span><\/p>\n<p><span style=\"font-weight: 400\">\u00a0\u00a0\u00a0\u00a0<\/span><b>Next<\/b><span style=\"font-weight: 400\"> value<\/span><\/p>\n<p><span style=\"font-weight: 400\">\u00a0\u00a0\u00a0\u00a0<\/span><b>Set<\/b><span style=\"font-weight: 400\"> arrayList = <\/span><b>Nothing<\/b><\/p>\n<p><span style=\"font-weight: 400\">\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"font-weight: 400\">\u2018 Return the new dictionary<\/span><\/p>\n<p><span style=\"font-weight: 400\">\u00a0\u00a0\u00a0\u00a0<\/span><b>Set<\/b><span style=\"font-weight: 400\"> SortDictionaryByValue = dict<\/span><\/p>\n<p><span style=\"font-weight: 400\">Done:<\/span><\/p>\n<p><span style=\"font-weight: 400\">\u00a0\u00a0\u00a0\u00a0<\/span><b>Exit<\/b> <b>Function<\/b><\/p>\n<p><span style=\"font-weight: 400\">eh:<\/span><\/p>\n<p><span style=\"font-weight: 400\">\u00a0\u00a0\u00a0\u00a0<\/span><b>If<\/b><span style=\"font-weight: 400\"> Err.Number = 450 <\/span><b>Then<\/b><\/p>\n<p><span style=\"font-weight: 400\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0Err.Raise vbObjectError + 100, <\/span><span style=\"font-weight: 400\">\u201cSortDictionaryByValue\u201d<\/span><span style=\"font-weight: 400\"> _<\/span><\/p>\n<p><span style=\"font-weight: 400\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0, <\/span><span style=\"font-weight: 400\">\u201cCannot sort the dictionary if the value is an object\u201d<\/span><\/p>\n<p><span style=\"font-weight: 400\">\u00a0\u00a0\u00a0\u00a0<\/span><b>End<\/b> <b>If<\/b><\/p>\n<p><b>End<\/b> <b>Function<\/b><\/p>\n<p><span style=\"font-weight: 400\">\u0110o\u1ea1n m\u00e3 d\u01b0\u1edbi \u0111\u00e2y h\u01b0\u1edbng d\u1eabn b\u1ea1n c\u00e1ch s\u1eed d\u1ee5ng SortDictionaryByValue<\/span><\/p>\n<h3><span class=\"ez-toc-section\" id=\"Giai_quyet_rac_roi_tu_dien\"><\/span><b>Gi\u1ea3i quy\u1ebft r\u1eafc r\u1ed1i t\u1eeb \u0111i\u1ec3n<\/b><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><span style=\"font-weight: 400\">Ph\u1ea7n n\u00e0y bao g\u1ed3m c\u00e1c l\u1ed7i ph\u1ed5 bi\u1ebfn m\u00e0 b\u1ea1n c\u00f3 th\u1ec3 g\u1eb7p ph\u1ea3i khi s\u1eed d\u1ee5ng T\u1eeb \u0111i\u1ec3n.<\/span><\/p>\n<h3><span class=\"ez-toc-section\" id=\"Quen_tham_chieu\"><\/span><b>Qu\u00ean tham chi\u1ebfu<\/b><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><span style=\"font-weight: 400\">S\u1ef1 c\u1ed1: B\u1ea1n nh\u1eadn \u0111\u01b0\u1ee3c th\u00f4ng b\u00e1o l\u1ed7i \u201cUser-defined type not defined\u201d\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400\">\u0110i\u1ec1u n\u00e0y th\u01b0\u1eddng x\u1ea3y ra khi b\u1ea1n t\u1ea1o T\u1eeb \u0111i\u1ec3n nh\u01b0ng qu\u00ean th\u00eam tham chi\u1ebfu.<\/span><\/p>\n<pre><strong>Dim dict As New Scripting.Dictionary<\/strong><\/pre>\n<p><span style=\"font-weight: 400\">Gi\u1ea3i ph\u00e1p: Ch\u1ecdn Tools-&gt;Reference t\u1eeb menu Visual Basic. \u0110\u00e1nh d\u1ea5u v\u00e0o h\u1ed9p b\u00ean c\u1ea1nh \u201cMicrosoft Scripting Runtime\u201d.<\/span><\/p>\n<p><span style=\"font-weight: 400\">Xem Ph\u1ea7n: T\u1ea1o t\u1eeb \u0111i\u1ec3n.<\/span><\/p>\n<h3><span class=\"ez-toc-section\" id=\"Exists_khong_hoat_dong\"><\/span><b>Exists kh\u00f4ng ho\u1ea1t \u0111\u1ed9ng<\/b><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><span style=\"font-weight: 400\">S\u1ef1 c\u1ed1: B\u1ea1n \u0111\u00e3 th\u00eam m\u1ed9t key v\u00e0o T\u1eeb \u0111i\u1ec3n nh\u01b0ng khi b\u1ea1n s\u1eed d\u1ee5ng h\u00e0m Exists, n\u00f3 tr\u1ea3 v\u1ec1 false<\/span><\/p>\n<p><span style=\"font-weight: 400\">\u0110\u00e2y th\u01b0\u1eddng l\u00e0 m\u1ed9t v\u1ea5n \u0111\u1ec1 v\u1edbi Ph\u00e2n bi\u1ec7t ch\u1eef hoa ch\u1eef th\u01b0\u1eddng (xem \u1edf tr\u00ean).\u00a0\u00a0<\/span><\/p>\n<pre><strong>dict.Add \"Apple\", 4\r\n\r\nIf dict.Exists(\"apple\") Then\r\n    MsgBox \"Exists\"\r\nElse\r\n    MsgBox \"Does not Exist\"\r\nEnd If<\/strong><\/pre>\n<p><span style=\"font-weight: 400\">\u0110o\u1ea1n m\u00e3 sau th\u00eam \u201cApple\u201d l\u00e0m key.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400\">Khi ch\u00fang ta ki\u1ec3m tra \u201capple\u201d, n\u00f3 s\u1ebd tr\u1ea3 v\u1ec1 false. \u0110i\u1ec1u n\u00e0y l\u00e0 do n\u00f3 t\u00ednh \u0111\u1ebfn tr\u01b0\u1eddng h\u1ee3p c\u1ee7a c\u00e1c ch\u1eef c\u00e1i:<\/span><\/p>\n<p><span style=\"font-weight: 400\">B\u1ea1n c\u00f3 th\u1ec3 \u0111\u1eb7t thu\u1ed9c t\u00ednh <\/span><b>CompareMode <\/b><span style=\"font-weight: 400\">th\u00e0nh vbTextCompare v\u00e0 \u0111i\u1ec1u n\u00e0y s\u1ebd b\u1ecf qua tr\u01b0\u1eddng h\u1ee3p:<\/span><\/p>\n<pre><strong>Dim dict As New Scripting.Dictionary\r\ndict.CompareMode = vbTextCompare<\/strong><\/pre>\n<p><span style=\"font-weight: 400\">Gi\u1ea3i ph\u00e1p: \u0110\u1eb7t CompareMode th\u00e0nh vbTextCompare \u0111\u1ec3 b\u1ecf qua tr\u01b0\u1eddng h\u1ee3p ho\u1eb7c \u0111\u1ea3m b\u1ea3o d\u1eef li\u1ec7u c\u1ee7a b\u1ea1n c\u00f3 \u0111\u00fang tr\u01b0\u1eddng h\u1ee3p.<\/span><\/p>\n<p><span style=\"font-weight: 400\">Xem Ph\u1ea7n: Key v\u00e0 <a href=\"http:\/\/blog.ezworkapp.com\/4-cach-de-viet-ham-vlookup-phan-biet-chu-hoa-va-chu-thuong-trong-excel.html\"><strong>Ph\u00e2n bi\u1ec7t ch\u1eef hoa ch\u1eef th\u01b0\u1eddng<\/strong><\/a><\/span><\/p>\n<h3><span class=\"ez-toc-section\" id=\"Loi_bieu_tuong\"><\/span><b>L\u1ed7i bi\u1ec3u t\u01b0\u1ee3ng<\/b><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><span style=\"font-weight: 400\">S\u1ef1 c\u1ed1: B\u1ea1n nh\u1eadn \u0111\u01b0\u1ee3c th\u00f4ng b\u00e1o l\u1ed7i \u201cObject variable or With block variable not set\u201d khi b\u1ea1n c\u1ed1 g\u1eafng s\u1eed d\u1ee5ng T\u1eeb \u0111i\u1ec3n.<\/span><\/p>\n<p><span style=\"font-weight: 400\">\u0110i\u1ec1u th\u01b0\u1eddng x\u1ea3y ra khi b\u1ea1n qu\u00ean s\u1eed d\u1ee5ng New tr\u01b0\u1edbc khi s\u1eed d\u1ee5ng T\u1eeb \u0111i\u1ec3n. V\u00ed d\u1ee5, \u0111o\u1ea1n m\u00e3 sau s\u1ebd g\u00e2y ra l\u1ed7i n\u00e0y<\/span><\/p>\n<pre><strong>Dim dict As Scripting.Dictionary\r\n' This line will give \"Object variable...\" error\r\ndict.Add \"Apple\", 4<\/strong><\/pre>\n<p><span style=\"font-weight: 400\">Gi\u1ea3i ph\u00e1p: S\u1eed d\u1ee5ng New keyword khi t\u1ea1o T\u1eeb \u0111i\u1ec3n<\/span><\/p>\n<pre><strong>Dim dict As New Scripting.Dictionary<\/strong><\/pre>\n<p><span style=\"font-weight: 400\">Hay\u00a0<\/span><\/p>\n<pre><strong>Dim dict As Scripting.Dictionary\r\nSet dict = New Scripting.Dictionary<\/strong><\/pre>\n<p><span style=\"font-weight: 400\">Xem ph\u1ea7n: <a href=\"http:\/\/blog.ezworkapp.com\/tu-dien-tong-hop-150-ham-thuong-dung-va-vi-du-trong-excel.html\"><strong>T\u1ea1o t\u1eeb \u0111i\u1ec3n<\/strong><\/a><\/span><\/p>\n<h3><span class=\"ez-toc-section\" id=\"Meo_huu_ich_de_go_roi_tu_dien\"><\/span><b>M\u1eb9o h\u1eefu \u00edch \u0111\u1ec3 g\u1ee1 r\u1ed1i t\u1eeb \u0111i\u1ec3n<\/b><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><span style=\"font-weight: 400\">N\u1ebfu b\u1ea1n \u0111ang \u0111i\u1ec1u tra m\u1ed9t v\u1ea5n \u0111\u1ec1 v\u1edbi T\u1eeb \u0111i\u1ec3n, c\u00f3 th\u1ec3 h\u1eefu \u00edch khi xem n\u1ed9i dung.<\/span><\/p>\n<p><span style=\"font-weight: 400\">S\u1eed d\u1ee5ng m\u00e3 sau \u0111\u1ec3 In t\u1eebng Key v\u00e0 Item \u0111\u1ebfn Immediate Window (Ctrl + G).<\/span><\/p>\n<pre><strong>' https:\/\/excelmacromastery.com\/\r\nSub PrintContents(dict As Scripting.Dictionary)\r\n    \r\n    Dim k As Variant\r\n    For Each k In dict.Keys\r\n        ' Print key and value\r\n        Debug.Print k, dict(k)\r\n    Next\r\n\r\nEnd Sub<\/strong><\/pre>\n<p><span style=\"font-weight: 400\">B\u1ea1n c\u00f3 th\u1ec3 s\u1eed d\u1ee5ng n\u00f3 nh\u01b0 th\u1ebf n\u00e0y<\/span><\/p>\n<pre><strong>Dim dict As Scripting.Dictionary\r\nSet dict = New Scripting.Dictionary\r\n\r\n' Add items to Dictionary here\r\n\r\n' Print the contents of the Dictionary to the Immediate Window\r\nPrintContents dict<\/strong><\/pre>\n<p><span style=\"font-weight: 400\">N\u1ebfu b\u1ea1n \u0111ang xem qua m\u00e3, b\u1ea1n c\u0169ng c\u00f3 th\u1ec3 th\u00eam <\/span><b>dict.Count<\/b><span style=\"font-weight: 400\"> v\u00e0o C\u1eeda s\u1ed5 xem \u0111\u1ec3 xem c\u00f3 bao nhi\u00eau item hi\u1ec7n c\u00f3 trong T\u1eeb \u0111i\u1ec3n. Nh\u1ea5p chu\u1ed9t ph\u1ea3i v\u00e0o b\u1ea5t k\u1ef3 \u0111\u00e2u trong c\u1eeda s\u1ed5 m\u00e3 v\u00e0 ch\u1ecdn <\/span><b>Add Watch<\/b><span style=\"font-weight: 400\">. Nh\u1eadp <\/span><b>dict.Count<\/b><span style=\"font-weight: 400\"> v\u00e0o h\u1ed9p v\u0103n b\u1ea3n v\u00e0 nh\u1ea5p v\u00e0o Ok.<\/span><\/p>\n<p><span style=\"font-weight: 400\">B\u1ea1n c\u0169ng c\u00f3 th\u1ec3 s\u1eed d\u1ee5ng ch\u00ednh T\u1eeb \u0111i\u1ec3n t\u1eeb Watch. Th\u00eam <\/span><b>Dict <\/b><span style=\"font-weight: 400\">v\u00e0o c\u1eeda s\u1ed5 Watch. N\u1ebfu b\u1ea1n nh\u1ea5p v\u00e0o d\u1ea5u c\u1ed9ng, b\u1ea1n s\u1ebd th\u1ea5y n\u1ed9i dung c\u1ee7a T\u1eeb \u0111i\u1ec3n. \u0110i\u1ec1u n\u00e0y c\u00f3 th\u1ec3 h\u1eefu \u00edch nh\u01b0ng n\u00f3 ch\u1ec9 hi\u1ec3n th\u1ecb key ch\u1ee9 kh\u00f4ng hi\u1ec3n th\u1ecb item\u00a0\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400\">L\u01b0u \u00fd: B\u1ea1n ch\u1ec9 c\u00f3 th\u1ec3 xem Watch khi m\u00e3 \u0111ang ch\u1ea1y.<\/span><\/p>\n<p><span style=\"font-weight: 400\">H\u00e3y nh\u1edb r\u1eb1ng b\u1ea1n c\u00f3 th\u1ec3 t\u1ea3i xu\u1ed1ng t\u1ea5t c\u1ea3 c\u00e1c v\u00ed d\u1ee5 m\u00e3 t\u1eeb b\u00e0i \u0111\u0103ng. Ch\u1ec9 c\u1ea7n chuy\u1ec3n \u0111\u1ebfn ph\u1ea7n <\/span><span style=\"font-weight: 400\">t\u1ea3i xu\u1ed1ng<\/span><span style=\"font-weight: 400\"> \u1edf tr\u00ean c\u00f9ng.<\/span><\/p>\n<h2><span class=\"ez-toc-section\" id=\"Sao_chep_tu_dien_vao_mot_mang\"><\/span><b>Sao ch\u00e9p t\u1eeb \u0111i\u1ec3n v\u00e0o m\u1ed9t m\u1ea3ng<\/b><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><span style=\"font-weight: 400\">Nh\u01b0 ch\u00fang ta bi\u1ebft t\u1eeb \u0111i\u1ec3n \u0111\u01b0\u1ee3c t\u1ea1o th\u00e0nh t\u1eeb c\u00e1c c\u1eb7p Key v\u00e0 Gi\u00e1 tr\u1ecb. T\u1eeb \u0111i\u1ec3n c\u00f3 thu\u1ed9c t\u00ednh Keys l\u00e0 m\u1ed9t m\u1ea3ng c\u1ee7a t\u1ea5t c\u1ea3 c\u00e1c key v\u00e0 thu\u1ed9c t\u00ednh Items l\u00e0 m\u1ed9t m\u1ea3ng c\u1ee7a t\u1ea5t c\u1ea3 c\u00e1c item (t\u1ee9c l\u00e0 gi\u00e1 tr\u1ecb).<\/span><\/p>\n<p><span style=\"font-weight: 400\">V\u00ec c\u1ea3 hai thu\u1ed9c t\u00ednh n\u00e0y \u0111\u1ec1u l\u00e0 m\u1ea3ng, ch\u00fang ta c\u00f3 th\u1ec3 ghi ch\u00fang tr\u1ef1c ti\u1ebfp v\u00e0o m\u1ed9t trang t\u00ednh nh\u01b0 ch\u00fang ta s\u1ebd th\u1ea5y trong ph\u1ea7n ti\u1ebfp theo.\u00a0\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400\">N\u1ebfu ch\u00fang ta mu\u1ed1n sao ch\u00e9p m\u1ea3ng Keys ho\u1eb7c Items sang m\u1ed9t m\u1ea3ng m\u1edbi th\u00ec ch\u00fang ta c\u00f3 th\u1ec3 l\u00e0m \u0111i\u1ec1u \u0111\u00f3 r\u1ea5t d\u1ec5 d\u00e0ng nh\u01b0 sau:<\/span><\/p>\n<pre><strong>Dim arr As Variant\r\narr = dict.Keys<\/strong><\/pre>\n<p><span style=\"font-weight: 400\">V\u00ed d\u1ee5 sau \u0111\u00e2y sao ch\u00e9p c\u00e1c m\u1ea3ng <\/span><i><span style=\"font-weight: 400\">Keys <\/span><\/i><span style=\"font-weight: 400\">v\u00e0 <\/span><i><span style=\"font-weight: 400\">Items<\/span><\/i><span style=\"font-weight: 400\"> sang c\u00e1c m\u1ea3ng m\u1edbi. Sau \u0111\u00f3, n\u1ed9i dung c\u1ee7a c\u00e1c m\u1ea3ng m\u1edbi \u0111\u01b0\u1ee3c in v\u00e0o Immediate Window:<\/span><\/p>\n<pre><strong>Sub DictionaryToArray()\r\n    \r\n    ' Create dictionary and add entries\r\n    Dim dict As New Dictionary\r\n    dict.Add \"France\", 56\r\n    dict.Add \"USA\", 23\r\n    dict.Add \"Australia\", 34\r\n\r\n    ' Declare variant to use as array\r\n    Dim arr As Variant\r\n\r\n    ' Copy keys to array\r\n    arr = dict.Keys\r\n    ' Print array to Immediate Window(Ctrl + G to View)\r\n    Call PrintArrayToImmediate(arr, \"Keys:\")\r\n    \r\n    ' Copy items to array\r\n    arr = dict.Items\r\n    ' Print array to Immediate Window(Ctrl + G to View)\r\n    Call PrintArrayToImmediate(arr, \"Items:\")\r\n\r\nEnd Sub\r\n\r\n' Prints an array to the Immediate Window(Ctrl + G to View)\r\nSub PrintArrayToImmediate(arr As Variant, headerText As String)\r\n    \r\n    Debug.Print vbNewLine &amp; headerText\r\n    Dim entry As Variant\r\n    For Each entry In arr\r\n        Debug.Print entry\r\n    Next\r\n        \r\nEnd Sub<\/strong><\/pre>\n<p><span style=\"font-weight: 400\">Khi m\u00e3 \u0111\u01b0\u1ee3c ch\u1ea1y, b\u1ea1n s\u1ebd nh\u1eadn \u0111\u01b0\u1ee3c k\u1ebft qu\u1ea3 sau:<\/span><\/p>\n<p><span style=\"font-weight: 400\">L\u01b0u \u00fd r\u1eb1ng b\u1ea1n ch\u1ec9 c\u00f3 th\u1ec3 sao ch\u00e9p m\u1ea3ng <\/span><i><span style=\"font-weight: 400\">Items<\/span><\/i><span style=\"font-weight: 400\"> khi n\u00f3 ch\u1ee9a c\u00e1c ki\u1ec3u d\u1eef li\u1ec7u c\u01a1 b\u1ea3n nh\u01b0 chu\u1ed7i, d\u00e0i, ng\u00e0y, k\u00e9p, v.v. N\u1ebfu c\u00e1c item l\u00e0 \u0111\u1ed1i t\u01b0\u1ee3ng th\u00ec b\u1ea1n kh\u00f4ng th\u1ec3 sao ch\u00e9p ch\u00fang v\u00e0o m\u1ed9t m\u1ea3ng. Thay v\u00e0o \u0111\u00f3, b\u1ea1n s\u1ebd c\u1ea7n \u0111\u1ecdc qua t\u1eeb \u0111i\u1ec3n b\u1eb1ng c\u00e1ch s\u1eed d\u1ee5ng m\u1ed9t v\u00f2ng l\u1eb7p.<\/span><\/p>\n<h3><span class=\"ez-toc-section\" id=\"Viet_tu_dien_vao_trang_tinh\"><\/span><b>Vi\u1ebft t\u1eeb \u0111i\u1ec3n v\u00e0o trang t\u00ednh<\/b><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><span style=\"font-weight: 400\">Ch\u00fang ta c\u00f3 th\u1ec3 ghi c\u00e1c key ho\u1eb7c item T\u1eeb \u0111i\u1ec3n v\u00e0o trang t\u00ednh trong m\u1ed9t d\u00f2ng m\u00e3.<\/span><\/p>\n<p><span style=\"font-weight: 400\">Khi b\u1ea1n vi\u1ebft ra c\u00e1c key ho\u1eb7c item, ch\u00fang s\u1ebd \u0111\u01b0\u1ee3c ghi th\u00e0nh m\u1ed9t h\u00e0ng. N\u1ebfu b\u1ea1n mu\u1ed1n ghi ch\u00fang v\u00e0o m\u1ed9t c\u1ed9t, b\u1ea1n c\u00f3 th\u1ec3 s\u1eed d\u1ee5ng h\u00e0m WorksheetFunction.Transpose.<\/span><\/p>\n<pre><strong>Sub DictionaryToWorksheet()\r\n    \r\n    Dim dict As New Dictionary\r\n    \r\n    dict.Add \"France\", 56\r\n    dict.Add \"USA\", 23\r\n    dict.Add \"Australia\", 34\r\n    \r\n    Dim sh As Worksheet\r\n    Set sh = ThisWorkbook.Worksheets(\"Sheet1\")\r\n    \r\n    ' Write keys to range A1:C1\r\n    sh.Range(\"A1:C1\").Value = dict.Keys\r\n    \r\n    ' Write items to range A2:C2\r\n    sh.Range(\"A2:C2\").Value = dict.Items\r\n    \r\n    ' Write keys to range E1:E3\r\n    sh.Range(\"E1:E3\").Value = WorksheetFunction.Transpose(dict.Keys)\r\n    \r\n    ' Write items to range F1:F3\r\n    sh.Range(\"F1:F3\").Value = WorksheetFunction.Transpose(dict.Items)\r\n\r\nEnd Sub<\/strong><\/pre>\n<p><span style=\"font-weight: 400\">\u0110o\u1ea1n m\u00e3 d\u01b0\u1edbi \u0111\u00e2y hi\u1ec3n th\u1ecb c\u00e1c v\u00ed d\u1ee5 v\u1ec1 c\u00e1ch ghi T\u1eeb \u0111i\u1ec3n v\u00e0o trang t\u00ednh:<\/span><\/p>\n<h2><span class=\"ez-toc-section\" id=\"Vi_du_huu_ich_ve_tu_dien\"><\/span><b>V\u00ed d\u1ee5 h\u1eefu \u00edch v\u1ec1 t\u1eeb \u0111i\u1ec3n<\/b><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><span style=\"font-weight: 400\">C\u00e1ch d\u1ec5 nh\u1ea5t \u0111\u1ec3 th\u1ea5y \u0111\u01b0\u1ee3c l\u1ee3i \u00edch c\u1ee7a T\u1eeb \u0111i\u1ec3n l\u00e0 xem m\u1ed9t s\u1ed1 v\u00ed d\u1ee5 th\u1ef1c t\u1ebf v\u1ec1 vi\u1ec7c s\u1eed d\u1ee5ng n\u00f3. V\u00ec v\u1eady, trong ph\u1ea7n n\u00e0y ch\u00fang ta s\u1ebd xem x\u00e9t m\u1ed9t s\u1ed1 v\u00ed d\u1ee5. B\u1ea1n c\u00f3 th\u1ec3 l\u1ea5y c\u1eeda s\u1ed5 l\u00e0m vi\u1ec7c v\u00e0 m\u00e3 cho c\u00e1c v\u00ed d\u1ee5 n\u00e0y b\u1eb1ng c\u00e1ch nh\u1eadp email c\u1ee7a b\u1ea1n v\u00e0o b\u00ean d\u01b0\u1edbi:<\/span><\/p>\n<h3><span class=\"ez-toc-section\" id=\"Vi_du_1_%E2%80%93_Tong_gia_tri_don\"><\/span><b>V\u00ed d\u1ee5 1 \u2013 T\u1ed5ng gi\u00e1 tr\u1ecb \u0111\u01a1n<\/b><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><span style=\"font-weight: 400\">H\u00e3y xem m\u1ed9t v\u00ed d\u1ee5 th\u1ef1c t\u1ebf v\u1ec1 vi\u1ec7c s\u1eed d\u1ee5ng t\u1eeb \u0111i\u1ec3n. D\u1eef li\u1ec7u c\u1ee7a ch\u00fang ta cho v\u00ed d\u1ee5 n\u00e0y l\u00e0 c\u00e1c tr\u1eadn Chung k\u1ebft World Cup t\u1eeb n\u0103m 2014.<\/span><\/p>\n<p><span style=\"font-weight: 400\">Nhi\u1ec7m v\u1ee5 c\u1ee7a ch\u00fang ta \u1edf \u0111\u00e2y l\u00e0 l\u1ea5y s\u1ed1 b\u00e0n th\u1eafng ghi \u0111\u01b0\u1ee3c c\u1ee7a m\u1ed7i \u0111\u1ed9i.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400\">\u0110i\u1ec1u \u0111\u1ea7u ti\u00ean ch\u00fang ta c\u1ea7n l\u00e0m l\u00e0 \u0111\u1ecdc t\u1ea5t c\u1ea3 d\u1eef li\u1ec7u. \u0110o\u1ea1n m\u00e3 sau \u0111\u00e2y \u0111\u1ecdc qua t\u1ea5t c\u1ea3 c\u00e1c tr\u1eadn \u0111\u1ea5u v\u00e0 in t\u00ean c\u1ee7a hai \u0111\u1ed9i tham gia.<\/span><\/p>\n<p><span style=\"font-weight: 400\">\u0110i\u1ec1u ch\u00fang ta mu\u1ed1n l\u00e0m b\u00e2y gi\u1edd l\u00e0 l\u01b0u tr\u1eef t\u1eebng \u0111\u1ed9i v\u00e0 nh\u1eefng b\u00e0n th\u1eafng m\u00e0 h\u1ecd ghi \u0111\u01b0\u1ee3c. Khi ch\u00fang ta g\u1eb7p m\u1ed9t \u0111\u1ed9i l\u1ea7n \u0111\u1ea7u ti\u00ean, ch\u00fang ta th\u00eam t\u00ean l\u00e0m Key v\u00e0 s\u1ed1 b\u00e0n th\u1eafng l\u00e0m Item.<\/span><\/p>\n<p><span style=\"font-weight: 400\">N\u1ebfu \u0111\u1ed9i \u0111\u00e3 \u0111\u01b0\u1ee3c th\u00eam v\u00e0o th\u00ec ch\u00fang ta s\u1ebd c\u1ed9ng t\u1ed5ng s\u1ed1 b\u00e0n th\u1eafng m\u00e0 h\u1ecd ghi \u0111\u01b0\u1ee3c trong tr\u1eadn \u0111\u1ea5u hi\u1ec7n t\u1ea1i.\u00a0\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400\">Ch\u00fang ta c\u00f3 th\u1ec3 s\u1eed d\u1ee5ng d\u00f2ng sau \u0111\u1ec3 th\u00eam m\u1ee5c ti\u00eau cho \u0111\u1ed9i hi\u1ec7n t\u1ea1i:<\/span><\/p>\n<p><span style=\"font-weight: 400\">D\u00f2ng n\u00e0y r\u1ea5t m\u1ea1nh.\u00a0\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400\">N\u1ebfu c\u00e1c \u0111\u1ed9i t\u1ed3n t\u1ea1i trong T\u1eeb \u0111i\u1ec3n, c\u00e1c b\u00e0n th\u1eafng hi\u1ec7n t\u1ea1i \u0111\u01b0\u1ee3c th\u00eam v\u00e0o t\u1ed5ng s\u1ed1 b\u00e0n th\u1eafng hi\u1ec7n t\u1ea1i c\u1ee7a \u0111\u1ed9i \u0111\u00f3.\u00a0\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400\">N\u1ebfu \u0111\u1ed9i kh\u00f4ng t\u1ed3n t\u1ea1i trong T\u1eeb \u0111i\u1ec3n th\u00ec n\u00f3 s\u1ebd t\u1ef1 \u0111\u1ed9ng th\u00eam \u0111\u1ed9i v\u00e0o T\u1eeb \u0111i\u1ec3n v\u00e0 \u0111\u1eb7t gi\u00e1 tr\u1ecb cho c\u00e1c m\u1ee5c ti\u00eau.<\/span><\/p>\n<p><span style=\"font-weight: 400\">V\u00ed d\u1ee5, h\u00e3y t\u01b0\u1edfng t\u01b0\u1ee3ng T\u1eeb \u0111i\u1ec3n c\u00f3 m\u1ed9t m\u1ee5c nh\u1eadp<\/span><\/p>\n<p><b>Key, Value<\/b><\/p>\n<p><i><span style=\"font-weight: 400\">Brazil, 5<\/span><\/i><\/p>\n<p><span style=\"font-weight: 400\">Sau \u0111\u00f3<\/span><\/p>\n<p><span style=\"font-weight: 400\">s\u1ebd c\u1eadp nh\u1eadt t\u1eeb \u0111i\u1ec3n \u0111\u1ec3 b\u00e2y gi\u1edd n\u00f3 tr\u00f4ng nh\u01b0 th\u1ebf n\u00e0y<\/span><\/p>\n<p><b>Key, Value<\/b><\/p>\n<p><i><span style=\"font-weight: 400\">Brazil, 8<\/span><\/i><\/p>\n<p><i><span style=\"font-weight: 400\">France, 3<\/span><\/i><\/p>\n<p><span style=\"font-weight: 400\">\u0110i\u1ec1u n\u00e0y gi\u00fap ch\u00fang ta kh\u00f4ng ph\u1ea3i vi\u1ebft m\u00e3 nh\u01b0 th\u1ebf n\u00e0y:<\/span><\/p>\n<p><span style=\"font-weight: 400\">Ch\u00fang ta vi\u1ebft c\u00e1c gi\u00e1 tr\u1ecb t\u1eeb T\u1eeb \u0111i\u1ec3n v\u00e0o trang t\u00ednh nh\u01b0 sau:<\/span><\/p>\n<p><span style=\"font-weight: 400\">\u2018 Write the data from the dictionary to the worksheet<\/span><\/p>\n<p><span style=\"font-weight: 400\">\u2018 https:\/\/excelmacromastery.com\/vba-dictionary<\/span><\/p>\n<p><b>Private<\/b> <b>Sub<\/b><span style=\"font-weight: 400\"> WriteDictionary(dict <\/span><b>As<\/b><span style=\"font-weight: 400\"> Scripting.Dictionary _<\/span><\/p>\n<p><span style=\"font-weight: 400\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0, shReport <\/span><b>As<\/b><span style=\"font-weight: 400\"> Worksheet)<\/span><\/p>\n<p><span style=\"font-weight: 400\">\u00a0\u00a0\u00a0\u00a0ClearData shReport<\/span><\/p>\n<p><span style=\"font-weight: 400\">\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"font-weight: 400\">\u2018 Write the keys<\/span><\/p>\n<p><span style=\"font-weight: 400\">\u00a0\u00a0\u00a0\u00a0shReport.Range(<\/span><span style=\"font-weight: 400\">\u201cA1\u201d<\/span><span style=\"font-weight: 400\">).Resize(dict.Count, 1).Value = WorksheetFunction.Transpose(dict.Keys)<\/span><span style=\"font-weight: 400\">\u00a0 \u00a0\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400\">\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"font-weight: 400\">\u2018 Write the items<\/span><\/p>\n<p><span style=\"font-weight: 400\">\u00a0\u00a0\u00a0\u00a0shReport.Range(<\/span><span style=\"font-weight: 400\">\u201cB1\u201d<\/span><span style=\"font-weight: 400\">).Resize(dict.Count, 1).Value = WorksheetFunction.Transpose(dict.Items)<\/span><\/p>\n<p><b>End<\/b> <b>Sub<\/b><\/p>\n<p><span style=\"font-weight: 400\">Ch\u00fang ta r\u00f5 r\u00e0ng mu\u1ed1n \u0111i\u1ec3m s\u1ed1 \u0111\u01b0\u1ee3c s\u1eafp x\u1ebfp. N\u00f3 l\u00e0 d\u1ec5 d\u00e0ng h\u01a1n nhi\u1ec1u \u0111\u1ec3 \u0111\u1ecdc theo c\u00e1ch n\u00e0y. Kh\u00f4ng c\u00f3 c\u00e1ch n\u00e0o d\u1ec5 d\u00e0ng \u0111\u1ec3 s\u1eafp x\u1ebfp m\u1ed9t T\u1eeb \u0111i\u1ec3n. C\u00e1ch th\u1ef1c hi\u1ec7n l\u00e0 sao ch\u00e9p t\u1ea5t c\u1ea3 c\u00e1c m\u1ee5c v\u00e0o m\u1ed9t m\u1ea3ng. S\u1eafp x\u1ebfp m\u1ea3ng v\u00e0 sao ch\u00e9p c\u00e1c item tr\u1edf l\u1ea1i T\u1eeb \u0111i\u1ec3n.<\/span><\/p>\n<p><span style=\"font-weight: 400\">Nh\u1eefng g\u00ec ch\u00fang ta c\u00f3 th\u1ec3 l\u00e0m l\u00e0 s\u1eafp x\u1ebfp d\u1eef li\u1ec7u khi n\u00f3 \u0111\u00e3 \u0111\u01b0\u1ee3c ghi v\u00e0o trang t\u00ednh. Ch\u00fang ta c\u00f3 th\u1ec3 s\u1eed d\u1ee5ng m\u00e3 sau \u0111\u1ec3 th\u1ef1c hi\u1ec7n vi\u1ec7c n\u00e0y:<\/span><\/p>\n<p><span style=\"font-weight: 400\">Sub GetTotals cu\u1ed1i c\u00f9ng c\u1ee7a ch\u00fang ta tr\u00f4ng nh\u01b0 th\u1ebf n\u00e0y:<\/span><\/p>\n<p><span style=\"font-weight: 400\">Khi b\u1ea1n ch\u1ea1y m\u00e3 n\u00e0y, b\u1ea1n s\u1ebd nh\u1eadn \u0111\u01b0\u1ee3c k\u1ebft qu\u1ea3 sau<\/span><\/p>\n<h3><span class=\"ez-toc-section\" id=\"Vi_du_2_%E2%80%93_Xu_ly_nhieu_gia_tri\"><\/span><b>V\u00ed d\u1ee5 2 \u2013 X\u1eed l\u00fd nhi\u1ec1u gi\u00e1 tr\u1ecb<\/b><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><span style=\"font-weight: 400\">Ch\u00fang ta s\u1ebd s\u1eed d\u1ee5ng d\u1eef li\u1ec7u t\u1eeb ph\u1ea7n <\/span><span style=\"font-weight: 400\">Nhi\u1ec1u gi\u00e1 tr\u1ecb<\/span><span style=\"font-weight: 400\"> \u1edf tr\u00ean.<\/span><\/p>\n<p><span style=\"font-weight: 400\">H\u00e3y t\u01b0\u1edfng t\u01b0\u1ee3ng d\u1eef li\u1ec7u n\u00e0y b\u1eaft \u0111\u1ea7u t\u1ea1i \u00f4 A1. Sau \u0111\u00f3, ch\u00fang ta c\u00f3 th\u1ec3 s\u1eed d\u1ee5ng \u0111o\u1ea1n m\u00e3 d\u01b0\u1edbi \u0111\u00e2y \u0111\u1ec3 \u0111\u1ecdc v\u00e0o t\u1eeb \u0111i\u1ec3n.\u00a0\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400\">M\u00e3 n\u00e0y bao g\u1ed3m hai m\u1ee5c \u0111\u0103ng k\u00fd \u0111\u1ec3 hi\u1ec3n th\u1ecb d\u1eef li\u1ec7u:<\/span><\/p>\n<ol>\n<li style=\"font-weight: 400\"><i><span style=\"font-weight: 400\">WriteToImmediate<\/span><\/i><span style=\"font-weight: 400\"> in n\u1ed9i dung c\u1ee7a t\u1eeb \u0111i\u1ec3n v\u00e0o Immediate Window.\u00a0<\/span><\/li>\n<li style=\"font-weight: 400\"><i><span style=\"font-weight: 400\">WriteToWorksheet<\/span><\/i><span style=\"font-weight: 400\"> ghi n\u1ed9i dung c\u1ee7a t\u1eeb \u0111i\u1ec3n v\u00e0o trang t\u00ednh \u0111\u01b0\u1ee3c g\u1ecdi l\u00e0 Output.<\/span><\/li>\n<\/ol>\n<p><span style=\"font-weight: 400\">\u0110\u1ec3 ch\u1ea1y v\u00ed d\u1ee5 n\u00e0y:<\/span><\/p>\n<ol>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">T\u1ea1o m\u1ed9t trang t\u00ednh c\u00f3 t\u00ean l\u00e0 Kh\u00e1ch h\u00e0ng.\u00a0\u00a0<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">Th\u00eam d\u1eef li\u1ec7u tr\u00ean v\u00e0o trang t\u00ednh b\u1eaft \u0111\u1ea7u t\u1eeb \u00f4 A1.\u00a0\u00a0<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">T\u1ea1o m\u1ed9t trang t\u00ednh c\u00f3 t\u00ean l\u00e0 Output v\u00e0 \u0111\u1ec3 tr\u1ed1ng.\u00a0<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">\u0110i t\u1edbi Visual Basic Editor(Alt + F11).\u00a0\u00a0<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">Ch\u1ecdn Tools-&gt;Reference v\u00e0 sau \u0111\u00f3 ch\u1ecdn \u201cMicrosoft Scripting Runtime\u201d t\u1eeb danh s\u00e1ch.\u00a0\u00a0<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">T\u1ea1o m\u1ed9t m\u00f4-\u0111un l\u1edbp m\u1edbi v\u00e0 th\u00eam \u0111o\u1ea1n m\u00e3 \u0111\u1ea7u ti\u00ean t\u1eeb b\u00ean d\u01b0\u1edbi.\u00a0\u00a0<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">T\u1ea1o m\u1ed9t m\u00f4-\u0111un ti\u00eau chu\u1ea9n m\u1edbi v\u00e0 th\u00eam \u0111o\u1ea1n m\u00e3 th\u1ee9 hai t\u1eeb b\u00ean d\u01b0\u1edbi.\u00a0\u00a0<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">Nh\u1ea5n F5 \u0111\u1ec3 ch\u1ea1y v\u00e0 ch\u1ecdn <\/span><i><span style=\"font-weight: 400\">Main <\/span><\/i><span style=\"font-weight: 400\">t\u1eeb menu.\u00a0\u00a0<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">Ki\u1ec3m tra mmediateWindow (Ctrl + G) v\u00e0 trang t\u00ednh \u0110\u1ea7u ra \u0111\u1ec3 xem k\u1ebft qu\u1ea3.<\/span><\/li>\n<\/ol>\n<h3><span class=\"ez-toc-section\" id=\"Vi_du_3_%E2%80%93_Tinh_tong_nhieu_gia_tri\"><\/span><b>V\u00ed d\u1ee5 3 \u2013 T\u00ednh t\u1ed5ng nhi\u1ec1u gi\u00e1 tr\u1ecb\u00a0<\/b><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><span style=\"font-weight: 400\">Trong v\u00ed d\u1ee5 n\u00e0y, ch\u00fang ta s\u1ebd th\u1ef1c hi\u1ec7n m\u1ed9t b\u1ea3n c\u1eadp nh\u1eadt nh\u1ecf cho V\u00ed d\u1ee5 2. Trong v\u00ed d\u1ee5 \u0111\u00f3, ch\u1ec9 c\u00f3 m\u1ed9t m\u1ee5c nh\u1eadp cho m\u1ed7i kh\u00e1ch h\u00e0ng trong d\u1eef li\u1ec7u.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400\">L\u1ea7n n\u00e0y s\u1ebd c\u00f3 nhi\u1ec1u m\u1ee5c nh\u1eadp cho m\u1ed9t s\u1ed1 kh\u00e1ch h\u00e0ng v\u00e0 ch\u00fang ta mu\u1ed1n t\u00ednh t\u1ed5ng Amount v\u00e0 t\u1ed5ng Items cho t\u1eebng kh\u00e1ch h\u00e0ng.\u00a0\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400\">Xem t\u1eadp d\u1eef li\u1ec7u c\u1eadp nh\u1eadt b\u00ean d\u01b0\u1edbi:<\/span><\/p>\n<p><span style=\"font-weight: 400\">L\u01b0u \u00fd: N\u1ebfu b\u1ea1n ch\u1ea1y m\u00e3 \u201cExample 2\u201d tr\u00ean d\u1eef li\u1ec7u c\u00f3 nhi\u1ec1u b\u1ea3n sao c\u1ee7a CustomerID, n\u00f3 s\u1ebd th\u00f4ng b\u00e1o l\u1ed7i \u201cKey already exists error\u201d.<\/span><\/p>\n<p><span style=\"font-weight: 400\">Khi n\u00e0o b\u1ea1n s\u1eed d\u1ee5ng t\u1eeb \u0111i\u1ec3n<\/span><\/p>\n<p><span style=\"font-weight: 400\">V\u1eady khi n\u00e0o b\u1ea1n n\u00ean s\u1eed d\u1ee5ng VBA Dictionary? Khi b\u1ea1n c\u00f3 m\u1ed9t nhi\u1ec7m v\u1ee5 trong \u0111\u00f3:<\/span><\/p>\n<ol>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">B\u1ea1n c\u00f3 m\u1ed9t danh s\u00e1ch c\u00e1c m\u1ee5c duy nh\u1ea5t, v\u00ed d\u1ee5: qu\u1ed1c gia, s\u1ed1 h\u00f3a \u0111\u01a1n, t\u00ean v\u00e0 \u0111\u1ecba ch\u1ec9 kh\u00e1ch h\u00e0ng, id d\u1ef1 \u00e1n, t\u00ean s\u1ea3n ph\u1ea9m, v.v.\u00a0<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">B\u1ea1n c\u1ea7n truy xu\u1ea5t gi\u00e1 tr\u1ecb c\u1ee7a m\u1ed9t m\u1eb7t h\u00e0ng duy nh\u1ea5t.<\/span><\/li>\n<\/ol>\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-56.gif\"><br \/>\n<\/a>\n<\/div>\n","protected":false},"author":1,"featured_media":1897,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-1896","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\/1896","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=1896"}],"version-history":[{"count":0,"href":"https:\/\/blog.ezworkapp.com\/index.php\/wp-json\/wp\/v2\/posts\/1896\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.ezworkapp.com\/index.php\/wp-json\/wp\/v2\/media\/1897"}],"wp:attachment":[{"href":"https:\/\/blog.ezworkapp.com\/index.php\/wp-json\/wp\/v2\/media?parent=1896"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.ezworkapp.com\/index.php\/wp-json\/wp\/v2\/categories?post=1896"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.ezworkapp.com\/index.php\/wp-json\/wp\/v2\/tags?post=1896"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}