IT编程技术

天行健,君子以自强不息;地势坤,君子以厚德载物;

【VBA实战】通用模块

2023-6-30 博主:Splendor EXCEL VBA实战


'---------------------------------------------------------------------------------------
' Procedure : dicDeWeight
' Author    : lipenghui
' Date      : 2018/11/13
' Purpose   : 字典去重
'      方法 : .Exists()
'           : .RemoveAll
'---------------------------------------------------------------------------------------
'
Public Function dicDeWeight(arrData)
    Set d = CreateObject("scripting.dictionary")
    For i = 1 To UBound(arrData)
        If arrData(i, 1) <> "" Then
            d(arrData(i, 1)) = ""
        End If
    Next
    dicDeWeight = d.keys
End Function

'---------------------------------------------------------------------------------------
' Procedure : getData
' Author    : lipenghui
' Date      : 2018/8/28
' Purpose   : 1,sht sheet页对象
'             2,strCearchCol iEnd获取行对应列
'             3,strRng 获取值的单元格范围 列:"A2:B"
'---------------------------------------------------------------------------------------
'
Public Function getData(sht As Object, strSearchCol As String, strRng As String, iRow)
    With sht
        iEnd = .Range(strSearchCol & Rows.Count).End(xlUp).Row
        If iEnd < iRow Then iEnd = iRow
        getData = .Range(strRng & iEnd).Value
    End With
End Function



'---------------------------------------------------------------------------------------
' Procedure : getStrColoum
' Author    : lipenghui
' Date      : 2018/7/27
' Purpose   : 数字转换列号
'---------------------------------------------------------------------------------------
'
Function getStrColoum(what)
    Set mc = Cells(1, what)
    getStrColoum = Mid(mc.Address, 2, Len(mc.Address) - 3)
End Function