🎯 Mục tiêu bài học
Sau bài học này, bạn sẽ:
✅ Tạo và quản lý Named Ranges (static + dynamic)
✅ Convert data thành Excel Tables (Ctrl + T)
✅ Sử dụng Structured References: [@Column], Table[Column]
✅ Kết hợp Tables + PivotTables cho auto-update
✅ Hiểu Data Model và Relationships giữa tables
Thời gian: 30 phút | Độ khó: Intermediate | Yêu cầu: Hoàn thành Bài 6 - Data Validation
📖 Bảng Thuật Ngữ Quan Trọng
| Thuật ngữ | Tiếng Việt | Mô tả |
|---|---|---|
| Named Range | Vùng đặt tên | Đặt tên cho cells thay vì dùng địa chỉ |
| Excel Table | Bảng Excel | Structured range với auto-features |
| Structured Reference | Tham chiếu cấu trúc | [@Column] syntax trong Tables |
| Name Manager | Quản lý tên | Dialog quản lý tất cả named ranges |
| Dynamic Named Range | Vùng tên động | Range tự expand khi thêm data |
| Total Row | Dòng tổng | Auto-calculated row cuối Table |
| Data Model | Mô hình dữ liệu | Multiple tables + relationships |
| Auto-Expand | Tự mở rộng | Table tự lớn khi thêm data |
| Banded Rows | Dòng xen kẽ | Zebra stripes formatting |
| Scope | Phạm vi | Workbook hoặc Sheet level |
Checkpoint
Named Range đặt tên cho cells, Excel Table là structured range, Structured Reference dùng [@Column]. Cả ba giúp formulas dễ đọc và maintain. Bạn phân biệt được chưa?
📛 2. Named Ranges
2.1 Named Range là gì?
Named Range = Đặt tên cho vùng cells thay vì dùng địa chỉ.
=SUM(B2:B100)khó hiểu=SUM(Revenue)Dễ đọc hơn! ✅=VLOOKUP(A2, $G$2:$I$50, 2, FALSE)khó hiểu=VLOOKUP(A2, ProductTable, 2, FALSE)Dễ đọc hơn! ✅2.2 Tạo Named Range
Cách 1: Name Box
- Select range B2:B100
- Click Name Box (góc trái trên)
- Gõ "Revenue" → Enter
Cách 2: Formulas → Define Name
Name: RevenueScope: WorkbookRefers to: =Sheet1!$B$2:$B$100Comment: "Monthly revenue data"Cách 3: Create from Selection
Select A1:B100 (bao gồm header "Revenue")Formulas → Create from Selection → ☑ Top Row→ Tự tạo Named Range "Revenue" = B2:B1002.3 Quản lý Named Ranges
Formulas → Name Manager (Ctrl + F3)
📛 Name Manager
| Name | Value | Refers To | Scope |
|---|---|---|---|
| Revenue | {45K...} | =Sheet1!$B$2:$B$100 | Workbook |
| Regions | {N,S...} | =Sheet1!$A$2:$A$100 | Workbook |
| Tax_Rate | 0.1 | =Sheet1!$G$1 | Workbook |
2.4 Sử dụng trong Formulas
=Revenue * Tax_Rate=SUMIF(Regions, "North", Revenue)=VLOOKUP(A2, ProductTable, 2, FALSE)Source: =RegionListdrop-down từ named rangeNamed Range cho constants (Tax_Rate, Discount_Rate) giúp thay đổi 1 chỗ → update tất cả formulas. Không cần tìm và sửa từng cell!
Checkpoint
Named Range biến cell addresses thành tên có nghĩa. 3 cách tạo: Name Box, Define Name, Create from Selection. Constants dùng Named Range → update 1 chỗ. Bạn đã thử chưa?
🔄 3. Dynamic Named Ranges
OFFSET Formula
DynamicRevenue = OFFSET(Sheet1!$B$1, 1, 0, COUNTA(Sheet1!$B:$B)-1, 1)Start: $B$1Offset down 1 rowskip headerWidth: 1 columnHeight: COUNTA($B:$B)-1đếm non-empty - headerDynamic Named Range tự mở rộng khi thêm data — không cần update range manually. Tuy nhiên, Excel Tables (Ctrl+T) cũng auto-expand và dễ dùng hơn. Chọn tùy tình huống!
Checkpoint
OFFSET tạo dynamic range tự expand khi thêm data. Nhưng Excel Tables là giải pháp hiện đại hơn — cũng auto-expand mà dễ dùng hơn. Bạn biết khi nào chọn cái nào chưa?
📊 4. Excel Tables (Ctrl + T)
4.1 Table là gì?
Excel Table = Structured data range với auto-features.
Tạo Table:
- Select data range (bao gồm headers)
Ctrl + T→ Check "My table has headers" → OK
4.2 Table Benefits
| Feature | Normal Range | Excel Table |
|---|---|---|
| Auto-expand | ❌ | ✅ Thêm row → tự mở rộng |
| Auto-format | ❌ | ✅ Zebra stripes |
| Auto-filter | Manual | ✅ Built-in |
| Structured Refs | ❌ | ✅ [@Column] syntax |
| Total Row | Manual formulas | ✅ Toggle on/off |
| Named auto | ❌ | ✅ Table name = Named Range |
4.3 Table Features
Auto-expand:
Nhập data vào row mới ngay dưới table→ Table tự mở rộng→ Formulas tự copy→ Formatting tự apply→ Charts tự updateTotal Row:
Table Design → ☑ Total RowLaptop 15000 10Phone 8000 25Tablet 6000 15─────────────────────────────Total 29000 50Click để đổi: Sum, Avg, Count...Banding Rows / Rename:
☑ Banded Rowszebra stripes☑ Header Rowfreeze headersRename: Table Design → Table Name: "SalesData"Luôn rename Tables ngay sau khi tạo! "SalesData" rõ nghĩa hơn "Table1". Tên table cũng trở thành Named Range — dùng trong formulas, PivotTables, VBA.
Checkpoint
Excel Table (Ctrl+T) có 6 ưu điểm: auto-expand, auto-format, auto-filter, structured refs, total row, auto-named. Luôn rename table ngay sau khi tạo. Bạn đã convert data sang Table chưa?
🔗 5. Structured References
5.1 Syntax
=SUM(SalesData[Revenue])=[@Revenue] * [@Quantity]=SalesData[[#Headers],[Revenue]]=SalesData[[#Totals],[Revenue]]=SalesData=SalesData[[Revenue]:[Cost]]5.2 So sánh với Cell References
=SUM($C$2:$C$100)Hết 100 rows → sai ❌=D2*E2Copy xuống → đúng=SUM(SalesData[Revenue])Auto-expand → luôn đúng ✅=[@Price]*[@Quantity]Rõ nghĩa, auto-copy ✅5.3 Calculated Columns
=[@Revenue]-[@Cost]Type vào header "Profit"→ Excel tự điền formula cho all rows!=SUMIF(SalesData[Region], "North", SalesData[Revenue])Checkpoint
Structured References: [@Column] cho current row, Table[Column] cho toàn cột. Auto-expand, dễ đọc, không bao giờ sai range. Bạn đã viết formula với structured refs chưa?
🔀 6. Tables + PivotTables & Data Model
6.1 Table → PivotTable
1. Data trong Table → Auto-expand2. Create PivotTable từ Table3. Thêm data mới vào Table4. PivotTable Refresh → Tự include data mới!Normal: Thêm data → Change PT source → RefreshTable: Thêm data → Refresh → Done! ✅6.2 Data Model
Multiple Tables + Relationships = Data Model📦Orders
| ID | ProductID |
|---|---|
| 1 | P001 |
| 2 | P002 |
💻Products
| ProductID | Name |
|---|---|
| P001 | Laptop |
| P002 | Phone |
✅Joined Result
| ID | ProductID | Name |
|---|---|---|
| 1 | P001 | Laptop |
| 2 | P002 | Phone |
Data → Relationships → Create Relationship → PivotTable từ Data Model = Cross-table analysis
Data Model cho phép PivotTable sử dụng data từ nhiều tables cùng lúc — không cần VLOOKUP nối trước. Đây là bước đầu tiến vào Power Pivot!
Checkpoint
Table + PivotTable = auto-update khi thêm data. Data Model = multiple tables với relationships → cross-table PivotTable. Chuẩn bị cho Power Pivot! Bạn đã thử chưa?
⚖️ 7. Named Ranges vs Tables
Khi nào dùng gì?
| Scenario | Named Range | Table |
|---|---|---|
| Constants (Tax Rate) | ✅ | ❌ |
| Data entry tables | ❌ | ✅ |
| Formula readability | ✅ | ✅ |
| Auto-expand | Cần OFFSET | ✅ Built-in |
| Multiple sheets | ✅ | ✅ |
| Data validation lists | ✅ | ✅ |
| PivotTable source | OK | ✅ Better |
Best Practice: Dùng Tables cho data + Named Ranges cho constants
Checkpoint
Named Ranges cho constants và cross-sheet references. Tables cho data sets cần auto-expand. Best practice: dùng cả hai — Tables cho data, Named Ranges cho constants. Bạn đã áp dụng chưa?
🏋️ 8. Thực hành
Kết hợp Named Ranges, Tables, và Structured References trong cùng workbook!
Exercise 1: Convert to Tables
- Mở file sales data từ bài trước
- Convert data range thành Table (
Ctrl + T) - Rename table: "SalesData"
- Thêm Total Row: Sum Revenue, Avg Quantity
- Thêm 5 rows mới → Verify auto-expand
Exercise 2: Structured References
Thêm calculated columns vào table:
💡 Xem đáp án
Profit = [@Revenue] - [@Cost]Margin = [@Profit] / [@Revenue]Status = IF([@Margin]>0.3, "High", IF([@Margin]>0.15, "Medium", "Low"))Exercise 3: Named Range System
Tạo system cho report:
- Named Range:
Tax_Rate= 10% - Named Range:
Discount_Rate= 5% - Named Range:
RegionList= North, South, East, West - Use trong: =[@Revenue] * (1 - Discount_Rate) * (1 + Tax_Rate)
Checkpoint
Bạn đã tạo được Table với structured references và Named Ranges cho constants chưa? Thử kết hợp cả hai: =[@Revenue] * (1 - Discount_Rate) * (1 + Tax_Rate) phải hoạt động!
� 9. Tổng Kết
Kiến thức đã học
| Chủ đề | Nội dung chính | Tầm quan trọng |
|---|---|---|
| Named Ranges | Tạo, quản lý, dynamic OFFSET | Formula readability |
| Excel Tables | Auto-expand, format, total row | Data management |
| Structured Refs | [@Column], Table[Column] | Modern formulas |
| Tables + PivotTable | Auto-update data source | Workflow efficiency |
| Data Model | Relationships between tables | Advanced analysis |
| Best Practices | Tables cho data, Names cho constants | Professional Excel |
Câu hỏi tự kiểm tra
- Named Range khác Table structured reference thế nào?
- OFFSET dùng để tạo dynamic range như thế nào?
- Khi nào nên dùng Table thay vì Named Range?
- Data Model dùng để làm gì?
Bài tiếp theo: Power Query Basics — Import, clean, transform data tự động
Key Takeaways:
- Named Ranges giúp formula dễ đọc hơn, dynamic OFFSET cho auto-expand
- Excel Tables (
Ctrl+T) tự mở rộng, auto-format, có total row - Structured References ([@Column], Table[Column]) — modern formulas
- Tables + PivotTable auto-update data source — workflow efficiency
- Tables cho data, Named Ranges cho constants — best practice
