Mẹo nhỏ: Để tìm kiếm chính xác các bài viết của MzOffice.org, hãy search trên Google với cú pháp: "Từ khóa" + "MzOffice".(Ví dụ: học Excel + mzoffice) -> Tìm kiếm ngay

Hàm CHAR trong Excel giúp chuyển đổi mã số thành ký tự tương ứng, hỗ trợ xử lý văn bản và định dạng dữ liệu hiệu quả. Bài viết này hướng dẫn chi tiết cách sử dụng hàm CHAR kèm ví dụ cụ thể và bảng mã ANSI để bạn áp dụng ngay vào công việc.

Giới thiệu về hàm CHAR trong Excel

Hàm CHAR là một hàm cơ bản nhưng cực kỳ hữu ích trong Excel, giúp chuyển đổi mã số (theo bảng mã ASCII hoặc ANSI) thành ký tự tương ứng. Hàm này thường được sử dụng để thêm các ký tự đặc biệt, định dạng văn bản, hoặc xử lý dữ liệu một cách linh hoạt. Bài viết này sẽ giúp bạn hiểu rõ cách sử dụng hàm CHAR, kèm theo bảng mã ANSI để bạn dễ dàng tra cứu và ứng dụng.

1. Cú pháp của hàm CHAR

Hàm CHAR có cú pháp đơn giản như sau:

=CHAR(number)

Trong đó:

  • number: Mã số của ký tự cần chuyển đổi (theo bảng mã ASCII hoặc ANSI).

2. Cách sử dụng hàm CHAR

Hàm CHAR được sử dụng trong nhiều tình huống khác nhau, bao gồm:

  • Thêm ký tự đặc biệt: Ví dụ, ký tự xuống dòng (CHAR(10)) hoặc dấu cách không ngắt (CHAR(160)).
  • Định dạng văn bản: Kết hợp với các hàm khác để tạo chuỗi văn bản có cấu trúc.
  • Xử lý dữ liệu: Loại bỏ hoặc thay thế các ký tự không mong muốn trong chuỗi văn bản.

3. Ví dụ cụ thể về hàm CHAR

Ví dụ 1: Thêm ký tự xuống dòng

Giả sử bạn muốn kết hợp nội dung từ ô A1 (“Họ và tên”) và ô B1 (“Địa chỉ”) với ký tự xuống dòng, bạn có thể sử dụng công thức:

=A1 & CHAR(10) & B1

Kết quả trả về sẽ là:

Họ và tên
Địa chỉ

(Lưu ý: Để hiển thị ký tự xuống dòng, bạn cần bật chế độ “Wrap Text” trong Excel).

Ví dụ 2: Tạo dấu cách không ngắt

Nếu bạn muốn thêm dấu cách không ngắt giữa các từ, bạn có thể sử dụng:

="Từ" & CHAR(160) & "này"

Kết quả trả về sẽ là “Từ này” với dấu cách không ngắt.

Ví dụ 3: Thêm ký tự đặc biệt vào chuỗi văn bản

Để thêm ký tự © (bản quyền), bạn có thể sử dụng:

="Bản quyền " & CHAR(169) & " 2025"

Kết quả trả về sẽ là “Bản quyền © 2025”.

4. Bảng mã ANSI phổ biến

Dưới đây là một số mã ANSI thường dùng và ký tự tương ứng:

Codesymbol
ascii code0NULL(Null character)
ascii code1SOH(Start of Header)
ascii code2STX(Start of Text)
ascii code3ETX(End of Text)
ascii code4EOT(End of Transmission)
ascii code5ENQ(Enquiry)
ascii code6ACK(Acknowledgement)
ascii code7BEL(Bell)
ascii code8BS(Backspace)
ascii code9HT(Horizontal Tab)
ascii code10LF(Line feed)
ascii code11VT(Vertical Tab)
ascii code12FF(Form feed)
ascii code13CR(Carriage return)
ascii code14SO(Shift Out)
ascii code15SI(Shift In)
ascii code16DLE(Data link escape)
ascii code17DC1(Device control 1)
ascii code18DC2(Device control 2)
ascii code19DC3(Device control 3)
ascii code20DC4(Device control 4)
ascii code21NAK(Negative acknowledgement)
ascii code22SYN(Synchronous idle)
ascii code23ETB(End of transmission block)
ascii code24CAN(Cancel)
ascii code25EM(End of medium)
ascii code26SUB(Substitute)
ascii code27ESC(Escape)
ascii code28FS(File separator)
ascii code29GS(Group separator)
ascii code30RS(Record separator)
ascii code31US(Unit separator)
ascii code32 (Space)
ascii code33!(Exclamation mark)
ascii code34"(Quotation mark ; quotes)
ascii code35#(Number sign)
ascii code36$(Dollar sign)
ascii code37%(Percent sign)
ascii code38&(Ampersand)
ascii code39'(Apostrophe)
ascii code40((round brackets or parentheses)
ascii code41)(round brackets or parentheses)
ascii code42*(Asterisk)
ascii code43+(Plus sign)
ascii code44,(Comma)
ascii code45-(Hyphen)
ascii code46.(Dot , full stop)
ascii code47/(Slash)
ascii code480(number zero)
ascii code491(number one)
ascii code502(number two)
ascii code513(number three)
ascii code524(number four)
ascii code535(number five)
ascii code546(number six)
ascii code557(number seven)
ascii code568(number eight)
ascii code579(number nine)
ascii code58:(Colon)
ascii code59;(Semicolon)
ascii code60<(Less-than sign)
ascii code61=(Equals sign)
ascii code62>(Greater-than sign ; Inequality)
ascii code63?(Question mark)
ascii code64@(At sign)
ascii code65A(Capital A)
ascii code66B(Capital B)
ascii code67C(Capital C)
ascii code68D(Capital D)
ascii code69E(Capital E)
ascii code70F(Capital F)
ascii code71G(Capital G)
ascii code72H(Capital H)
ascii code73I(Capital I)
ascii code74J(Capital J)
ascii code75K(Capital K)
ascii code76L(Capital L)
ascii code77M(Capital M)
ascii code78N(Capital N)
ascii code79O(Capital O)
ascii code80P(Capital P)
ascii code81Q(Capital Q)
ascii code82R(Capital R)
ascii code83S(Capital S)
ascii code84T(Capital T)
ascii code85U(Capital U)
ascii code86V(Capital V)
ascii code87W(Capital W)
ascii code88X(Capital X)
ascii code89Y(Capital Y)
ascii code90Z(Capital Z)
ascii code91[(square brackets or box brackets)
ascii code92\(Backslash)
ascii code93](square brackets or box brackets)
ascii code94^(Caret or circumflex accent)
ascii code95_(underscore , understrike , underbar or low line)
ascii code96`(Grave accent)
ascii code97a(Lowercase a )
ascii code98b(Lowercase b )
ascii code99c(Lowercase c )
ascii code100d(Lowercase d )
ascii code101e(Lowercase e )
ascii code102f(Lowercase f )
ascii code103g(Lowercase g )
ascii code104h(Lowercase h )
ascii code105i(Lowercase i )
ascii code106j(Lowercase j )
ascii code107k(Lowercase k )
ascii code108l(Lowercase l )
ascii code109m(Lowercase m )
ascii code110n(Lowercase n )
ascii code111o(Lowercase o )
ascii code112p(Lowercase p )
ascii code113q(Lowercase q )
ascii code114r(Lowercase r )
ascii code115s(Lowercase s )
ascii code116t(Lowercase t )
ascii code117u(Lowercase u )
ascii code118v(Lowercase v )
ascii code119w(Lowercase w )
ascii code120x(Lowercase x )
ascii code121y(Lowercase y )
ascii code122z(Lowercase z )
ascii code123{(curly brackets or braces)
ascii code124|(vertical-bar, vbar, vertical line or vertical slash)
ascii code125}(curly brackets or braces)
ascii code126~(Tilde ; swung dash)
ascii code127DEL(Delete)
ascii code128Ç(Majuscule C-cedilla)
ascii code129ü(letter "u" with umlaut or diaeresis ; "u-umlaut")
ascii code130é(letter "e" with acute accent or "e-acute")
ascii code131â(letter "a" with circumflex accent or "a-circumflex")
ascii code132ä(letter "a" with umlaut or diaeresis ; "a-umlaut")
ascii code133à(letter "a" with grave accent)
ascii code134å(letter "a" with a ring)
ascii code135ç(Minuscule c-cedilla)
ascii code136ê(letter "e" with circumflex accent or "e-circumflex")
ascii code137ë(letter "e" with umlaut or diaeresis ; "e-umlaut")
ascii code138è(letter "e" with grave accent)
ascii code139ï(letter "i" with umlaut or diaeresis ; "i-umlaut")
ascii code140î(letter "i" with circumflex accent or "i-circumflex")
ascii code141ì(letter "i" with grave accent)
ascii code142Ä(letter "A" with umlaut or diaeresis ; "A-umlaut")
ascii code143Å(Capital letter "A" with a ring)
ascii code144É(Capital letter "E" with acute accent or "E-acute")
ascii code145æ(Latin diphthong "ae" in lowercase)
ascii code146Æ(Latin diphthong "AE" in uppercase)
ascii code147ô(letter "o" with circumflex accent or "o-circumflex")
ascii code148ö(letter "o" with umlaut or diaeresis ; "o-umlaut")
ascii code149ò(letter "o" with grave accent)
ascii code150û(letter "u" with circumflex accent or "u-circumflex")
ascii code151ù(letter "u" with grave accent)
ascii code152ÿ(Lowercase letter "y" with diaeresis)
ascii code153Ö(letter "O" with umlaut or diaeresis ; "O-umlaut")
ascii code154Ü(letter "U" with umlaut or diaeresis ; "U-umlaut")
ascii code155ø(slashed zero or empty set)
ascii code156£(Pound sign ; symbol for the pound sterling)
ascii code157Ø(slashed zero or empty set)
ascii code158×(multiplication sign)
ascii code159ƒ(function sign ; f with hook sign ; florin sign )
ascii code160á(letter "a" with acute accent or "a-acute")
ascii code161í(letter "i" with acute accent or "i-acute")
ascii code162ó(letter "o" with acute accent or "o-acute")
ascii code163ú(letter "u" with acute accent or "u-acute")
ascii code164ñ(letter "n" with tilde ; enye)
ascii code165Ñ(letter "N" with tilde ; enye)
ascii code166ª(feminine ordinal indicator)
ascii code167º(masculine ordinal indicator)
ascii code168¿(Inverted question marks)
ascii code169®(Registered trademark symbol)
ascii code170¬(Logical negation symbol)
ascii code171½(One half)
ascii code172¼(Quarter or one fourth)
ascii code173¡(Inverted exclamation marks)
ascii code174«(Angle quotes or guillemets)
ascii code175»(Guillemets or angle quotes)
ascii code176
ascii code177
ascii code178
ascii code179(Box drawing character)
ascii code180(Box drawing character)
ascii code181Á(Capital letter "A" with acute accent or "A-acute")
ascii code182Â(letter "A" with circumflex accent or "A-circumflex")
ascii code183À(letter "A" with grave accent)
ascii code184©(Copyright symbol)
ascii code185(Box drawing character)
ascii code186(Box drawing character)
ascii code187(Box drawing character)
ascii code188(Box drawing character)
ascii code189¢(Cent symbol)
ascii code190¥(YEN and YUAN sign)
ascii code191(Box drawing character)
ascii code192(Box drawing character)
ascii code193(Box drawing character)
ascii code194(Box drawing character)
ascii code195(Box drawing character)
ascii code196(Box drawing character)
ascii code197(Box drawing character)
ascii code198ã(Lowercase letter "a" with tilde or "a-tilde")
ascii code199Ã(Capital letter "A" with tilde or "A-tilde")
ascii code200(Box drawing character)
ascii code201(Box drawing character)
ascii code202(Box drawing character)
ascii code203(Box drawing character)
ascii code204(Box drawing character)
ascii code205(Box drawing character)
ascii code206(Box drawing character)
ascii code207¤(generic currency sign)
ascii code208ð(Lowercase letter "eth")
ascii code209Ð(Capital letter "Eth")
ascii code210Ê(letter "E" with circumflex accent or "E-circumflex")
ascii code211Ë(letter "E" with umlaut or diaeresis ; "E-umlaut")
ascii code212È(letter "E" with grave accent)
ascii code213ı(lowercase dot less i)
ascii code214Í(Capital letter "I" with acute accent or "I-acute")
ascii code215Î(letter "I" with circumflex accent or "I-circumflex")
ascii code216Ï(letter "I" with umlaut or diaeresis ; "I-umlaut")
ascii code217(Box drawing character)
ascii code218(Box drawing character)
ascii code219(Block)
ascii code220(Bottom half block)
ascii code221¦(vertical broken bar)
ascii code222Ì(letter "I" with grave accent)
ascii code223(Top half block)
ascii code224Ó(Capital letter "O" with acute accent or "O-acute")
ascii code225ß(letter "Eszett" ; "scharfes S" or "sharp S")
ascii code226Ô(letter "O" with circumflex accent or "O-circumflex")
ascii code227Ò(letter "O" with grave accent)
ascii code228õ(letter "o" with tilde or "o-tilde")
ascii code229Õ(letter "O" with tilde or "O-tilde")
ascii code230µ(Lowercase letter "Mu" ; micro sign or micron)
ascii code231þ(Lowercase letter "Thorn")
ascii code232Þ(Capital letter "thorn")
ascii code233Ú(Capital letter "U" with acute accent or "U-acute")
ascii code234Û(letter "U" with circumflex accent or "U-circumflex")
ascii code235Ù(letter "U" with grave accent)
ascii code236ý(Lowercase letter "y" with acute accent)
ascii code237Ý(Capital letter "Y" with acute accent)
ascii code238¯(macron symbol)
ascii code239´(Acute accent)
ascii code240­(Hyphen)
ascii code241±(Plus-minus sign)
ascii code242(underline or underscore)
ascii code243¾(three quarters)
ascii code244(paragraph sign or pilcrow)
ascii code245§(Section sign)
ascii code246÷(The division sign ; Obelus)
ascii code247¸(cedilla)
ascii code248°(degree symbol )
ascii code249¨(Diaeresis)
ascii code250·(Interpunct or space dot)
ascii code251¹(superscript one)
ascii code252³(cube or superscript three)
ascii code253²(Square or superscript two)
ascii code254(black square)
ascii code255nbsp(non-breaking space or no-break space)

5. Lưu ý khi sử dụng hàm CHAR

  • Hàm CHAR chỉ hoạt động với các mã số trong phạm vi từ 1 đến 255 (theo bảng mã ANSI).
  • Đối với các ký tự Unicode, bạn cần sử dụng hàm UNICHAR thay vì CHAR.
  • Kết quả của hàm CHAR phụ thuộc vào bảng mã được sử dụng trong hệ thống của bạn.

6. Ứng dụng thực tế của hàm CHAR

  • Tạo định dạng văn bản chuyên nghiệp: Kết hợp hàm CHAR với các hàm khác như CONCATENATE hoặc TEXT để tạo chuỗi văn bản có cấu trúc.
  • Xử lý dữ liệu nhanh chóng: Sử dụng hàm CHAR để loại bỏ hoặc thay thế các ký tự không mong muốn trong chuỗi văn bản.
  • Thêm ký tự đặc biệt vào báo cáo: Sử dụng hàm CHAR để thêm các ký tự như dấu xuống dòng, dấu cách không ngắt, hoặc ký tự bản quyền vào báo cáo.

Kết luận
Hàm CHAR trong Excel là một công cụ mạnh mẽ giúp bạn xử lý và định dạng văn bản một cách linh hoạt. Bằng cách nắm vững cú pháp, cách sử dụng và bảng mã ANSI, bạn có thể áp dụng hàm CHAR vào nhiều tình huống khác nhau trong công việc. Hãy thử sử dụng hàm CHAR và khám phá sự tiện lợi mà nó mang lại!

5/5 - (1 vote)

LEAVE A REPLY

Please enter your comment!
Please enter your name here