This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Private Sub SpinButton1_Change() | |
| SpinButton1.Min = 1 | |
| SpinButton1.Max = Sheet1.Range("F" & Rows.Count).End(xlUp).Value | |
| End Sub |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Sub Spinner_getData() | |
| Dim ws As Worksheet 'Thiết lập biến ws là Sheet đang mở | |
| Set ws = ActiveSheet | |
| Dim rngData As Range 'Thiết lập vùng bảng dữ liệu bắt đầu từ ô D3 | |
| Set rngData = Range(ws.Range("D3").End(xlDown), ws.Range("D3").End(xlToRight)) | |
| Dim Data As Variant 'Xét nội dung trong bảng Dữ liệu | |
| Data = rngData.Value | |
| Dim iCell As Integer 'Vị trí kết quả Spinner | |
| iCell = ws.Range("M2").Value |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Sub XuatPDF() | |
| 'Tìm dòng cuối bảng kê | |
| Dim maxR As Integer | |
| maxR = Sheet1.Range("F" & Rows.Count).End(xlUp).Value 'Luu ý cột cần xác định ở đây là cột F | |
| 'Xác định đường dẫn tới thư mục lưu kết quả | |
| Set xSht = ActiveSheet | |
| Set xFileDlg = Application.FileDialog(msoFileDialogFolderPicker) | |
| If xFileDlg.Show = True Then |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Sub Sort_NoHeader() 'Excel VBA for a sort (ascending). | |
| Range("A2", Range("G" & Rows.Count).End(xlUp)).Sort [D2], xlAscending | |
| End Sub |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Sub Sort_Header() 'Sort in Ascending with Header | |
| Range("A1", Range("G" & Rows.Count).End(xlUp)).Sort [D2], xlAscending, Header:=xlYes | |
| End Sub |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Option Explicit | |
| Sub Sort_Multi_Sheet() 'Excel VBA to Sort All Sheets in Workbook in Ascending Order | |
| Dim ws As Worksheet | |
| For Each ws In ThisWorkbook.Worksheets | |
| ws.Range("A2", ws.Range("G" & Rows.Count).End(xlUp)).Sort [D2], 1 | |
| Next ws | |
| End Sub |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Sub Loc_BCCT() | |
| 'Biện luận trường hợp không phát sinh | |
| If Range("N1").Value = 0 Then | |
| MsgBox "Khong co du lieu phat sinh" | |
| Range("H6:K26").ClearContents | |
| Exit Sub | |
| Else | |
| Application.ScreenUpdating = False | |
| 'Xóa dữ liệu cũ trong báo cáo | |
| Range("H6:K26").ClearContents |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Sub Xoa_Dong_Trong() 'Xóa dòng trống ở cột A | |
| On Error Resume Next 'Bẫy lỗi không có dòng trống | |
| Range("A3", Range("A65536").End(xlUp)).SpecialCells(4).EntireRow.Delete | |
| On Error GoTo 0 'Nếu xảy ra lỗi thì tới 0 | |
| End Sub |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Sub Loop_Test01() 'Ví dụ về vòng lặp lấy giá trị cho vùng từ A1 đến A10 | |
| Dim i As Integer | |
| For i=1 To 10 | |
| Range("A" & i).Value=i | |
| Next i | |
| End Sub |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Option Explicit | |
| Sub Loop_Test02() 'Vòng lặp kép 2 vòng | |
| Dim i As Integer | |
| Dim j As Integer | |
| For i = 1 To 2 | |
| For j = 2 To 6 | |
| If Cells(j, i) = "Book" Then Cells(j, 3) = "Yes" | |
| Next j |
OlderNewer