com

你的位置:丝袜制服 > com > 波多野结衣qvod VBA【代码】多条目汇总,汇总成果排序,多种智商,想路详解!

波多野结衣qvod VBA【代码】多条目汇总,汇总成果排序,多种智商,想路详解!

发布日期:2025-06-28 15:05    点击次数:164
楠里 足交 现实纲目波多野结衣qvod波多野结衣qvod 多条目汇总,汇总成果排序|完竣代码 1、在使命表Sheet1里,敕令按钮点击事件,调用汇总进程: Private Sub CmdSum1_Click() Call mySum1End SubPrivate Sub CmdSum2_Click() Call mySum2End Sub 2、在myModule里,mySum1进程,通过数组、字典、使命表排序智商,汇总和据: Sub mySum1()   ...

波多野结衣qvod VBA【代码】多条目汇总,汇总成果排序,多种智商,想路详解!

楠里 足交

现实纲目波多野结衣qvod波多野结衣qvod

多条目汇总,汇总成果排序|完竣代码

1、在使命表Sheet1里,敕令按钮点击事件,调用汇总进程:

Private Sub CmdSum1_Click()    Call mySum1End SubPrivate Sub CmdSum2_Click()    Call mySum2End Sub

2、在myModule里,mySum1进程,通过数组、字典、使命表排序智商,汇总和据:

Sub mySum1()    Dim ws As Worksheet, lastRow As Integer, lastCol As Integer    Dim dic As Object, dKey1, dKey2    Dim arr(), temp(), str() As String, rng As Range    Set ws = ThisWorkbook.Sheets("Sheet1")    Set dic = CreateObject("Scripting.Dictionary")    With ws        lastRow = .UsedRange.Rows.Count        lastCol = 5        arr = .Range(.Cells(1, 1), .Cells(lastRow, lastCol)).Value    End With    For i = 2 To UBound(arr)        If arr(i, 1) <> "" Then            dKey1 = arr(i, 1) & "|" & arr(i, 2)            If Not dic.exists(dKey1) Then                dic.Add dKey1, CreateObject("Scripting.Dictionary")            End If                        For j = 3 To 5                dKey2 = arr(1, j)                dic(dKey1)(dKey2) = dic(dKey1)(dKey2) + arr(i, j)            Next        End If    Next    ReDim temp(1 To dic.Count + 1, 1 To lastCol)    For i = 1 To lastCol        temp(1, i) = arr(1, i)    Next    m = 1    For Each dKey1 In dic.keys        str = Split(dKey1, "|")        m = m + 1        temp(m,户外露出 1) = str(0)        temp(m, 2) = str(1)        For i = 3 To 5            dKey2 = temp(1, i)            temp(m, i) = dic(dKey1)(dKey2)        Next    Next    ws.Range("J1").Resize(lastRow, lastCol).ClearContents    Set rng = ws.Range("J1").Resize(UBound(temp), UBound(temp, 2))    With rng        .Value2 = temp        Call SortRange(rng, .Columns(1), .Columns(2))    End WithEnd Sub

3、在myModule里,SortRange进程,通过两个关节字对一个Range进行排序,不错遴选数据是否包括标题行,默许包含:

Sub SortRange( _        rng As Range, _        primarySortKey As Range, _        secondarySortKey As Range, _        Optional IncludeHeader As Boolean = True)    '//按两列排序,默许数据包含标题    Dim ws As Worksheet    Set ws = rng.Parent    With ws.Sort        .SortFields.Clear        .SortFields.Add _            Key:=primarySortKey, _            SortOn:=xlSortOnValues, _            Order:=xlAscending, _            DataOption:=xlSortNormal        .SortFields.Add _            Key:=secondarySortKey, _            SortOn:=xlSortOnValues, _            Order:=xlAscending, _            DataOption:=xlSortNormal        .SetRange rng        If IncludeHeader Then            .Header = xlYes        Else            .Header = xlNo        End If        .MatchCase = False        .Orientation = xlTopToBottom        .SortMethod = xlPinYin        .Apply    End WithEnd Sub

4、在myModule里,mySum2进程波多野结衣qvod,通过数组、SortedList智商,汇总和据:

Sub mySum2()    Dim ws As Worksheet, lastRow As Integer, lastCol As Integer    Dim lst As Object, key1, key2    Dim arr(), temp(), str, rng As Range    Set ws = ThisWorkbook.Sheets("Sheet1")    Set lst = CreateObject("System.Collections.SortedList")    With ws        lastRow = .UsedRange.Rows.Count        lastCol = 5        arr = .Range(.Cells(1, 1), .Cells(lastRow, lastCol)).Value    End With    For i = 2 To UBound(arr)        If arr(i, 1) <> "" Then            key1 = arr(i, 1) & "|" & arr(i, 2)            If Not lst.contains(key1) Then                lst.Add key1, CreateObject("System.Collections.SortedList")            End If                        For j = 3 To 5                key2 = arr(1, j)                lst.Item(key1).Item(key2) = lst.Item(key1).Item(key2) + arr(i, j)'                lst(key1)(key2) = lst(key1)(key2) + arr(i, j)            Next        End If    Next    ReDim temp(1 To lst.Count + 1, 1 To lastCol)    For i = 1 To lastCol        temp(1, i) = arr(1, i)    Next    For i = 0 To lst.Count - 1        key1 = lst.getkey(i)        str = Split(key1, "|")        temp(i + 2, 1) = str(0)        temp(i + 2, 2) = str(1)        For j = 3 To 5            key2 = temp(1, j)            temp(i + 2, j) = lst.Item(key1).Item(key2)            'temp(i + 2, j) = lst(key1)(key2)        Next    Next    ws.Range("J1").Resize(lastRow, lastCol).ClearContents    Set rng = ws.Range("J1").Resize(UBound(temp), UBound(temp, 2))    With rng        .Value2 = temp    End WithEnd Sub
~~~~~~End~~~~~~ 本站仅提供存储职业,通盘现实均由用户发布,如发现存害或侵权现实,请点击举报。

上一篇:bad news 丝袜 2023年中国彩妆行业发展近况及竞争风光分析,彩妆家具功效化、护肤化成为行业趋势「图」
下一篇:波多野结衣qvod 上海十大风情万种好意思女红星!张敏江疏影孙俪谁最性感?
TOP