This file contains 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
'''''''''''''''''''''''''''''''''''' | |
' http://hocexcel.online | |
' source for createGUID: http://www.cpearson.com/excel/CreateGUID.aspx | |
' source for genGUID: http://stackoverflow.com/questions/7031347/how-can-i-generate-guids-in-excel | |
'''''''''''''''''''''''''''''''''''' | |
Option Explicit | |
'''''''''''''''''''''''''''''''''''' |
This file contains 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
Function SumByColor(CellColor As Range, rRange As Range) | |
'Thêm dòng này để công thức tự update với Excel 2010 trở lên | |
' Với Excel 2007, có thể dùng CTRL + ALT + F9 | |
Application.Volatile True | |
Dim cSum As Long | |
Dim ColIndex As Integer | |
ColIndex = CellColor.Interior.ColorIndex | |
For Each cl In rRange | |
If cl.Interior.ColorIndex = ColIndex Then |
This file contains 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
'https://www.hocexcel.online/vba-excel-doi-tuong-workbooks-worksheets-ranges.html | |
'dtnguyen | Học Excel Online | |
' Tham chiếu đến workbook hiện thời | |
ThisWorkbook | |
' Tham chiếu đến workbook đang làm việc | |
ActiveWorkbook | |
' Tham chiếu đến 1 Workbook đang mở |
This file contains 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
'https://www.hocexcel.online/vba-excel-doi-tuong-workbooks-worksheets-ranges.html | |
'dtnguyen | Học Excel Online | |
'Tham chiếu đến Sheet trong Workbook hiện | |
ThisWorkbook.Worksheets("[tên sheet]") | |
'hoặc sử dụng codename, ví dụ: Sheet1 | |
'Tham chiếu đến Sheet trong 1 workbook cụ thể | |
wk.Worksheets("[tên sheet]") |
This file contains 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 | |
Public Const SHEET_SETTINGS As String = "SETTINGS" | |
Public Const SHEET_DATA As String = "DATA" | |
Public Const UI_GAP As Integer = 5 | |
Public Const UI_LEFT As Integer = 10 | |
Public Const UI_LINE_HEIGHT As Integer = 16 | |
Public Const UI_FONT_SIZE As Integer = 8 | |
Sub showForm() | |
'Hiện ra Form nhập liệu |
This file contains 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
Dim currentTopPos As Double | |
Private Sub cmdSaveData_Click() | |
Dim settings As Variant | |
Dim info() As String | |
Dim index As Long | |
With Sheets(SHEET_SETTINGS) | |
ReDim info(1 To getLR(.Name, "A") - 1) | |
settings = .Range("A2:D" & getLR(.Name, "A")).Value |
This file contains 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 LBDMHH_Change() | |
Dim Id, i | |
Id = LBDMHH.ListIndex | |
With Me.LBDMHH | |
On Error Resume Next | |
This file contains 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 CMDADD_Click() | |
On Error Resume Next | |
Dim Arr(), i | |
Arr = Dic.Items | |
If ActiveCell.Column = 1 Then | |
This file contains 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 UserForm_Terminate() | |
Set Dic = Nothing | |
Erase sArray | |
End Sub |
This file contains 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 TXTFIND_Change() | |
Call WaitFor(0.05) | |
Dim Arr, i | |
If CBDMHH.Value = "ALL" Then | |
Arr = FilterMCLArray(sArray, 4, TXTFIND.Text, True) | |