{"id":11320,"date":"2025-01-15T02:30:52","date_gmt":"2025-01-15T02:30:52","guid":{"rendered":"https:\/\/blog.ezworkapp.com\/index.php\/2025\/01\/15\/cach-lay-ten-file-excel-vao-1-cell\/"},"modified":"2025-01-15T02:30:52","modified_gmt":"2025-01-15T02:30:52","slug":"cach-lay-ten-file-excel-vao-1-cell","status":"publish","type":"post","link":"https:\/\/blog.ezworkapp.com\/index.php\/2025\/01\/15\/cach-lay-ten-file-excel-vao-1-cell\/","title":{"rendered":"C\u00e1ch l\u1ea5y t\u00ean file Excel v\u00e0o 1 cell"},"content":{"rendered":"<div class=\"uk-panel uk-margin\" id=\"template-nJy84WMn#1\">\n<p>\u0110\u00f4i khi trong l\u00fac l\u00e0m vi\u1ec7c v\u1edbi file Excel, ch\u00fang ta s\u1ebd c\u1ea7n l\u1ea5y t\u00ean ho\u1eb7c \u0111\u01b0\u1eddng d\u1eabn t\u1edbi file \u0111\u00f3 v\u00e0 ghi n\u1ed9i dung n\u00e0y v\u00e0o trong m\u1ed9t cell c\u1ee7a Excel. R\u1ea5t may, trong Excel c\u00f3 1 h\u00e0m gi\u00fap ch\u00fang ta c\u00f3 th\u1ec3 l\u00e0m \u0111\u01b0\u1ee3c \u0111i\u1ec1u n\u00e0y m\u1ed9t c\u00e1ch r\u1ea5t \u0111\u01a1n gi\u1ea3n \u0111\u00f3 l\u00e0 h\u00e0m CELL. C\u00e1ch s\u1eed d\u1ee5ng h\u00e0m CELL n\u00e0y nh\u01b0 sau:<\/p>\n<p>T\u1ea1i \u00f4 c\u1ea7n ghi \u0111\u01b0\u1eddng d\u1eabn c\u1ee7a File Excel: nh\u1eadp v\u00e0o c\u00f4ng th\u1ee9c<\/p>\n<p><strong>=CELL(\u201cfilename\u201d)<\/strong><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-9119 aligncenter\" src=\"http:\/\/blog.ezworkapp.com\/wp-content\/uploads\/2025\/01\/get-workbook-name-cell-function.png\" alt=\"Get-Workbook-Name-CELL-function\" width=\"421\" height=\"97\" title=\"get-workbook-name-cell-function\"><\/p>\n<p>V\u00e0 b\u00e2y gi\u1edd, \u0111\u1ec3 l\u1ea5y ra \u0111\u01b0\u1eddng d\u1eabn v\u00e0 t\u00ean File, ch\u00fang ta s\u1ebd k\u1ebft h\u1ee3p c\u00e1c h\u00e0m quen thu\u1ed9c trong Excel l\u00e0 h\u00e0m SEARCH, h\u00e0m LEN, h\u00e0m MID, h\u00e0m RIGHT, h\u00e0m LEFT:<\/p>\n<p>L\u1ea5y \u0111\u01b0\u1eddng d\u1eabn:<\/p>\n<blockquote>\n<pre>=LEFT(CELL(\"filename\"),SEARCH(\"[\",CELL(\"filename\"))-1)<\/pre>\n<\/blockquote>\n<p>L\u1ea5y t\u00ean file:<\/p>\n<blockquote>\n<pre>=MID(CELL(\"filename\"),SEARCH(\"[\",CELL(\"filename\"))+1,\r\nSEARCH(\"]\",CELL(\"filename\"))-SEARCH(\"[\",CELL(\"filename\"))-1)<\/pre>\n<\/blockquote>\n<p>L\u1ea5y t\u00ean Sheet:<\/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\/2025\/01\/vba101_92019-nho-34.gif\" title=\"vba101_92019-nho-34\"><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\/2025\/01\/ex101_92019-nho-283.gif\" title=\"ex101_92019-nho-283\"><br \/>\n<\/a>\n<\/div>\n<\/div>\n<blockquote>\n<pre>=RIGHT(CELL(\"filename\"),LEN(CELL(\"filename\"))-SEARCH(\"]\",CELL(\"filename\")))<\/pre>\n<\/blockquote>\n<p>Ngo\u00e0i c\u00e1ch d\u00f9ng h\u00e0m CELL s\u1eb5n c\u00f3 \u1edf trong Excel, b\u1ea1n c\u00f3 th\u1ec3 s\u1eed d\u1ee5ng code VBA trong Excel \u0111\u1ec3 x\u1eed l\u00fd vi\u1ec7c n\u00e0y kh\u00e1 ng\u1eafn g\u1ecdn nh\u01b0 sau:<\/p>\n<p>L\u1ea5y t\u00ean file v\u00e0 \u0111\u01b0\u1eddng d\u1eabn \u0111\u1ea7y \u0111\u1ee7:<\/p>\n<blockquote>\n<pre>Function FullFileName(rng As Range) As String\r\nFullFileName = rng.Parent.Parent.FullName\r\nEnd Function<\/pre>\n<\/blockquote>\n<p>L\u1ea5y t\u00ean sheet:<\/p>\n<blockquote>\n<pre>Function SheetName(rng As Range) As String\r\nSheetName = rng.Parent.Name\r\nEnd Function<\/pre>\n<\/blockquote>\n<p>L\u1ea5y \u0111\u01b0\u1eddng d\u1eabn t\u1edbi file:<\/p>\n<blockquote>\n<pre>Function FilePath(rng As Range) As String\r\nFilePath = rng.Parent.Parent.Path\r\nEnd Function<\/pre>\n<\/blockquote>\n<p>R\u1ea5t nhi\u1ec1u ki\u1ebfn th\u1ee9c ph\u1ea3i kh\u00f4ng n\u00e0o? To\u00e0n b\u1ed9 nh\u1eefng ki\u1ebfn th\u1ee9c n\u00e0y c\u00e1c b\u1ea1n \u0111\u1ec1u c\u00f3 th\u1ec3 h\u1ecdc \u0111\u01b0\u1ee3c trong kh\u00f3a h\u1ecdc\u00a0<a href=\"http:\/\/bit.ly\/2w6YAe8\">EX101 \u2013 Excel t\u1eeb c\u01a1 b\u1ea3n t\u1edbi chuy\u00ean gia<\/a>\u00a0c\u1ee7a <a href=\"http:\/\/blog.ezworkapp.com\/\">H\u1ecdc Excel Online<\/a>. \u0110\u00e2y l\u00e0 kh\u00f3a h\u1ecdc gi\u00fap b\u1ea1n h\u1ec7 th\u1ed1ng ki\u1ebfn th\u1ee9c m\u1ed9t c\u00e1ch \u0111\u1ea7y \u0111\u1ee7, chi ti\u1ebft. H\u01a1n n\u1eefa kh\u00f4ng h\u1ec1 c\u00f3 gi\u1edbi h\u1ea1n v\u1ec1 th\u1eddi gian h\u1ecdc t\u1eadp n\u00ean b\u1ea1n c\u00f3 th\u1ec3 tho\u1ea3i m\u00e1i h\u1ecdc b\u1ea5t c\u1ee9 l\u00fac n\u00e0o, d\u1ec5 d\u00e0ng tra c\u1ee9u l\u1ea1i ki\u1ebfn th\u1ee9c khi c\u1ea7n. Hi\u1ec7n nay h\u1ec7 th\u1ed1ng \u0111ang c\u00f3 \u01b0u \u0111\u00e3i r\u1ea5t l\u1edbn cho b\u1ea1n khi \u0111\u0103ng k\u00fd tham gia kh\u00f3a h\u1ecdc\u00a0n\u00e0y. \u0110\u1ec3 bi\u1ebft th\u00eam th\u00f4ng tin chi ti\u1ebft v\u1ec1 kh\u00f3a h\u1ecdc, b\u1ea1n tham kh\u1ea3o t\u1ea1i \u0111\u00e2y:<\/p>\n<\/div>\n<div class=\"uk-panel uk-margin uk-width-xlarge\">\n<p>Click \u0111\u0103ng k\u00fd h\u1ecdc t\u1ea1i:<\/p>\n<p><a href=\"http:\/\/blog.ezworkapp.com\/khoa-hoc\" target=\"_blank\" rel=\"noopener\">T\u1ea5t c\u1ea3 kho\u00e1 h\u1ecdc\u00a0<span>\ud83d\udcd6<\/span><\/a><\/p>\n<p><a href=\"http:\/\/blog.ezworkapp.com\/huong-dan-kich-hoat-khoa-hoc-tai-hoc-excel-online.html\" target=\"_blank\" rel=\"noopener\">H\u01b0\u1edbng d\u1eabn k\u00edch ho\u1ea1t<\/a><\/p>\n<p>HKD H\u1ecdc Excel Online<br \/>S\u1ed1 \u0110K: 17A80048102<\/p>\n<\/div>\n<div class=\"uk-panel uk-text-small uk-margin uk-margin-remove-bottom uk-text-center\">\n<p>\u00a9  document.currentScript.insertAdjacentHTML(&#8216;afterend&#8217;, &#8221; + new Intl.DateTimeFormat(document.documentElement.lang, {year: &#8216;numeric&#8217;}).format() + &#8221;);  H\u1ecdc Excel Online. All rights reserved.<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<div class=\"ad-inserterpro\">\n<a href=\"https:\/\/hocexcel.online\/course\/preview\/vba101-tu-dong-hoa-excel-voi-lap-trinh-vba-cho-nguoi-moi-bat-dau\"><br \/>\n<img decoding=\"async\" src=\"http:\/\/blog.ezworkapp.com\/wp-content\/uploads\/2025\/01\/vba101_92019-nho-34.gif\"><br \/>\n<\/a>\n<\/div>\n","protected":false},"author":1,"featured_media":11321,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-11320","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-excel-co-ban"],"_links":{"self":[{"href":"https:\/\/blog.ezworkapp.com\/index.php\/wp-json\/wp\/v2\/posts\/11320","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=11320"}],"version-history":[{"count":0,"href":"https:\/\/blog.ezworkapp.com\/index.php\/wp-json\/wp\/v2\/posts\/11320\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.ezworkapp.com\/index.php\/wp-json\/wp\/v2\/media\/11321"}],"wp:attachment":[{"href":"https:\/\/blog.ezworkapp.com\/index.php\/wp-json\/wp\/v2\/media?parent=11320"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.ezworkapp.com\/index.php\/wp-json\/wp\/v2\/categories?post=11320"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.ezworkapp.com\/index.php\/wp-json\/wp\/v2\/tags?post=11320"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}