Skip to content

Instantly share code, notes, and snippets.

''''''''''''''''''''''''''''''''''''
' 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
''''''''''''''''''''''''''''''''''''
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
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"
'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ở
'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]")
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
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
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
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
Sub WaitFor(NumOfSeconds As Single)
Dim SngSec As Single
SngSec = Timer + NumOfSeconds
Do While Timer < SngSec
DoEvents
Loop
End Sub