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
Function bo_dau_tieng_viet(Text As String) As String | |
Dim AsciiDict As Object | |
Set AsciiDict = CreateObject("scripting.dictionary") | |
AsciiDict(192) = "A" | |
AsciiDict(193) = "A" | |
AsciiDict(194) = "A" | |
AsciiDict(195) = "A" | |
AsciiDict(196) = "A" | |
AsciiDict(197) = "A" | |
AsciiDict(199) = "C" |
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
Function Filter2DArray(ByVal sArray, ByVal ColIndex As Long, ByVal FindStr As String, ByVal HasTitle As Boolean) | |
Dim tmpArr, i As Long, j As Long, Arr, Dic, TmpStr, Tmp, Chk As Boolean, TmpVal As Double | |
On Error Resume Next | |
Set Dic = CreateObject("Scripting.Dictionary") | |
tmpArr = sArray | |
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 FilterMCLArray(ByVal sArray, ByVal TotalCol As Long, ByVal FindStr As String, ByVal HasTitle As Boolean) | |
Dim tmpArr, i As Long, j As Long, ColIndex As Long, K As Long, Arr, Dic, TmpStr, Tmp, Chk As Boolean, TmpVal As Double | |
On Error Resume Next | |
Set Dic = CreateObject("Scripting.Dictionary") | |
tmpArr = sArray | |
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
Sub WaitFor(NumOfSeconds As Single) | |
Dim SngSec As Single | |
SngSec = Timer + NumOfSeconds | |
Do While Timer < SngSec | |
DoEvents | |
Loop | |
End Sub |