- WorksheetFunction Vd :
Range(“A3”).Value = Application.WorksheetFunction.Average(Range(“A1:A2”)) Range(“A3”).Value = “=AVERAGE(A1:A2)”
- ScreenUpdating (Cập nhật màn hình)
Giả sử có đoạn code sau :
Dim i As Integer For i = 1 To 10000 Range(“A1”).Value = i Next i
Thay bằng :
Dim i As IntegerApplication.ScreenUpdating = False For i = 1 To 10000 Range(“A1”).Value = i
Next iApplication.ScreenUpdating = True
Kết quả code chạy nhanh hơn .
- DisplayAlerts (Hiển thị cảnh báo)
VD : Application.DisplayAlerts = False ActiveWorkbook.Close Application.DisplayAlerts = True
Không cho Excel hiển thị cảnh báo
- Calculation (Tính toán)
Vd :
Application.Calculation = xlCalculationManual Application.Calculation = xlCalculationAutomatic
- Range
VD :
Range(“B3”).Value = 2 Range(“A1:A4”).Value = 5 Range(“A1:A2,B3:C4”).Value = 10
- Cells
VD :
Cells(3, 2).Value = 2 Range(Cells(1, 1), Cells(4, 1)).Value = 5
- Khai báo một Range
Dim example As Range Set example = Range(“A1:C4”) example.Value = 8
- Workbooks.Add : Method Add của Workbooks tạo một workbook mới.
Thứ Năm, 31 tháng 3, 2016
VBA Excel - Tóm tắt Thuộc tính, đối tượng code ... thường sử dụng trong VBA
Artikel Terkait
- Public Function Chu(sotien) 'Function suu tam Dim tien, k, n As Integer Dim Nhom, S1, S2
- Public Function f_doikytu(chuoikytu1 As String, kytucu1 As String, kytumoi1 As String)
- Function CatTen(str As String) As String Dim mlen As Long Dim i As Long mlen = Len(s
- Public Function SuaNgay(NgayBatKy) ' Original Design 2002 If Not IsDate(NgayBatKy) Then
- * Đoạn code tự động thực hiện các mệnh lệnh khi mở file Excel : Sub auto_open() On Error
- Sub Create_Index() Dim wsSheet As Worksheet Dim ws As Worksheet Dim Counter As Long
Đăng ký:
Đăng Nhận xét (Atom)
EmoticonEmoticon