Trước tiên bạn tạo 1 Sheet có tên là Data để lưu trữ dữ liệu.
-Nhấn tổ hợp phím Alt+F11 để vào cửa sổ VBA
-Vào Insert\ Userform
-Vẽ 10 TextBox, 2 command button vào form và đặt tên cho chúng.
+ Tên nút command thứ nhất đặt tên cmdAdd, thứ 2 là cmdClose
+ Tên các textbox lần lược như sau: txtCont, txtName, txtAdd, txtTel, txtID, txtDate, txtLocal, txtAccount, txtnote, txtRemaks.
-Sau khi tạo xong các nút, bạn vào View\Code.
Cửa sổ code hiện ra, bạn copy và chép đoạn code sau vào đó.
* Cho nút Thêm
Mã nguồn PHP:
[COLOR=#000000]
[/COLOR][COLOR=#007700]Private [/COLOR][COLOR=#0000BB]Sub cmdAdd_Click[/COLOR][COLOR=#007700]()[/COLOR][COLOR=#0000BB]Dim iRow [/COLOR][COLOR=#007700]As [/COLOR][COLOR=#0000BB]LongDim ws [/COLOR][COLOR=#007700]As [/COLOR][COLOR=#0000BB]WorksheetSet ws [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#0000BB]Worksheets[/COLOR][COLOR=#007700]([/COLOR][COLOR=#DD0000]"DATA"[/COLOR][COLOR=#007700])[/COLOR][COLOR=#0000BB]iRow [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#0000BB]ws[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]Cells[/COLOR][COLOR=#007700]([/COLOR][COLOR=#0000BB]Rows[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]Count[/COLOR][COLOR=#007700], [/COLOR][COLOR=#0000BB]1[/COLOR][COLOR=#007700]) [/COLOR][COLOR=#0000BB]_[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]End[/COLOR][COLOR=#007700]([/COLOR][COLOR=#0000BB]xlUp[/COLOR][COLOR=#007700]).[/COLOR][COLOR=#0000BB]Offset[/COLOR][COLOR=#007700]([/COLOR][COLOR=#0000BB]1[/COLOR][COLOR=#007700], [/COLOR][COLOR=#0000BB]0[/COLOR][COLOR=#007700]).[/COLOR][COLOR=#0000BB]Row[/COLOR][COLOR=#007700]If [/COLOR][COLOR=#0000BB]Trim[/COLOR][COLOR=#007700]([/COLOR][COLOR=#0000BB]Me[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]txtCont[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]Value[/COLOR][COLOR=#007700]) = [/COLOR][COLOR=#DD0000]"" [/COLOR][COLOR=#0000BB]ThenMe[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]txtCont[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]SetFocusMsgBox [/COLOR][COLOR=#DD0000]"Vui long dien so hop dong"[/COLOR][COLOR=#007700], [/COLOR][COLOR=#0000BB]vbInformation[/COLOR][COLOR=#007700]Exit [/COLOR][COLOR=#0000BB]SubEnd [/COLOR][COLOR=#007700]If[/COLOR][COLOR=#0000BB]ws[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]Cells[/COLOR][COLOR=#007700]([/COLOR][COLOR=#0000BB]iRow[/COLOR][COLOR=#007700], [/COLOR][COLOR=#0000BB]1[/COLOR][COLOR=#007700]).[/COLOR][COLOR=#0000BB]Value [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#0000BB]Me[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]txtCont[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]Valuews[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]Cells[/COLOR][COLOR=#007700]([/COLOR][COLOR=#0000BB]iRow[/COLOR][COLOR=#007700], [/COLOR][COLOR=#0000BB]2[/COLOR][COLOR=#007700]).[/COLOR][COLOR=#0000BB]Value [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#0000BB]Me[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]txtName[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]Valuews[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]Cells[/COLOR][COLOR=#007700]([/COLOR][COLOR=#0000BB]iRow[/COLOR][COLOR=#007700], [/COLOR][COLOR=#0000BB]3[/COLOR][COLOR=#007700]).[/COLOR][COLOR=#0000BB]Value [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#0000BB]Me[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]txtAdd[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]Valuews[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]Cells[/COLOR][COLOR=#007700]([/COLOR][COLOR=#0000BB]iRow[/COLOR][COLOR=#007700], [/COLOR][COLOR=#0000BB]4[/COLOR][COLOR=#007700]).[/COLOR][COLOR=#0000BB]Value [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#0000BB]Me[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]txtTel[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]Valuews[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]Cells[/COLOR][COLOR=#007700]([/COLOR][COLOR=#0000BB]iRow[/COLOR][COLOR=#007700], [/COLOR][COLOR=#0000BB]5[/COLOR][COLOR=#007700]).[/COLOR][COLOR=#0000BB]Value [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#0000BB]Me[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]txtID[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]Valuews[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]Cells[/COLOR][COLOR=#007700]([/COLOR][COLOR=#0000BB]iRow[/COLOR][COLOR=#007700], [/COLOR][COLOR=#0000BB]6[/COLOR][COLOR=#007700]).[/COLOR][COLOR=#0000BB]Value [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#0000BB]Me[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]txtDate[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]Valuews[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]Cells[/COLOR][COLOR=#007700]([/COLOR][COLOR=#0000BB]iRow[/COLOR][COLOR=#007700], [/COLOR][COLOR=#0000BB]7[/COLOR][COLOR=#007700]).[/COLOR][COLOR=#0000BB]Value [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#0000BB]Me[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]txtLocal[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]Valuews[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]Cells[/COLOR][COLOR=#007700]([/COLOR][COLOR=#0000BB]iRow[/COLOR][COLOR=#007700], [/COLOR][COLOR=#0000BB]8[/COLOR][COLOR=#007700]).[/COLOR][COLOR=#0000BB]Value [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#0000BB]Me[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]txtAccount[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]Valuews[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]Cells[/COLOR][COLOR=#007700]([/COLOR][COLOR=#0000BB]iRow[/COLOR][COLOR=#007700], [/COLOR][COLOR=#0000BB]9[/COLOR][COLOR=#007700]).[/COLOR][COLOR=#0000BB]Value [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#0000BB]Me[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]txtnote[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]Valuews[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]Cells[/COLOR][COLOR=#007700]([/COLOR][COLOR=#0000BB]iRow[/COLOR][COLOR=#007700], [/COLOR][COLOR=#0000BB]10[/COLOR][COLOR=#007700]).[/COLOR][COLOR=#0000BB]Value [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#0000BB]Me[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]txtRemaks[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]ValueMe[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]txtCont[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]Value [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#DD0000]""[/COLOR][COLOR=#0000BB]Me[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]txtName[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]Value [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#DD0000]""[/COLOR][COLOR=#0000BB]Me[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]txtAdd[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]Value [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#DD0000]""[/COLOR][COLOR=#0000BB]Me[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]txtTel[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]Value [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#DD0000]""[/COLOR][COLOR=#0000BB]Me[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]txtDate[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]Value [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#DD0000]""[/COLOR][COLOR=#0000BB]Me[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]txtLocal[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]Value [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#DD0000]""[/COLOR][COLOR=#0000BB]Me[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]txtAccount[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]Value [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#DD0000]""[/COLOR][COLOR=#0000BB]Me[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]txtID[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]Value [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#DD0000]""[/COLOR][COLOR=#0000BB]Me[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]txtnote[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]Value [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#DD0000]""[/COLOR][COLOR=#0000BB]Me[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]txtRemaks[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]Value [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#DD0000]""[/COLOR][COLOR=#0000BB]Me[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]txtCont[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]SetFocusEnd Sub[/COLOR]
*Cho nút thoát.
Mã nguồn PHP:
[COLOR=#000000]
[/COLOR][COLOR=#007700]Private [/COLOR][COLOR=#0000BB]Sub cmdClose_Click[/COLOR][COLOR=#007700]()[/COLOR][COLOR=#0000BB]Unload MeEnd Sub[/COLOR]
Sau đó nhấn F5 chạy Form để nhập liệu thử
Chúc bạn thành công.
P/S: Sao diễn đàn mình không cho gửi Attach file vậy các bạn?
Nora Ephron là tiếng tăm huyền thoại của dòng phim lãng mạn, khôi hài và suy tôn ẩm thực của Hollywood - Ảnh: New York Times Tại buổi lễ tưởng vọng bà gần đây, 800 bạn bè và người thân - trong đó có...
Một số bí mật vây quanh Nora Ephron đã liên tục được công bố