国产精品天干天干,亚洲毛片在线,日韩gay小鲜肉啪啪18禁,女同Gay自慰喷水

歡迎光臨散文網(wǎng) 會員登陸 & 注冊

VBA——字典對象的常規(guī)用法和嵌套用法示例

2023-08-15 21:27 作者:ch_j  | 我要投稿

Rem 本視頻完整代碼

'方法一

Sub 字典匹配數(shù)據(jù)()

??Dim arr

??Dim i As Long

??Dim dict As Object

??Dim key As String

???

??arr = Sheets("長攤索引表").UsedRange.Value

??Set dict = CreateObject("Scripting.Dictionary")

???

??For i = LBound(arr, 1) + 1 To UBound(arr, 1)

????key = CStr(arr(i, 1))

?????

????If Not dict.Exists(key) Then

??????dict(key) = arr(i, 3)

????Else

??????dict(key) = dict(key) & "_" & arr(i, 3)

????End If

??Next i

???

??Dim brr

??Dim j As Long

??Dim key1

??Dim 新行 As Long

???

??brr = Sheets("輔材表").UsedRange.Value

??新行 = 2

??For j = LBound(brr, 1) + 1 To UBound(brr, 1)

????key1 = CStr(brr(j, 1))

?????

????If dict.Exists(key1) Then

??????If InStr(dict(key1), brr(j, 3)) > 0 Then

????????'數(shù)據(jù)滿足條件,需要存到【長攤表】中

????????With Sheets("長攤表")

??????????.Cells(新行, 1).Value = "'" & brr(j, 1)

??????????.Cells(新行, 2).Value = "'" & brr(j, 2)

??????????.Cells(新行, 3).Value = "'" & brr(j, 3)

????????End With

?????????

????????新行 = 新行 + 1

??????End If

????End If

??Next j

End Sub


'方法二

Sub 字典匹配數(shù)據(jù)_匹配3列_拼接key()

??Dim arr

??Dim i As Long

??Dim dict As Object

??Dim key As String

???

??arr = Sheets("長攤索引表").UsedRange.Value

??Set dict = CreateObject("Scripting.Dictionary")

???

??For i = LBound(arr, 1) + 1 To UBound(arr, 1)

????key = CStr(arr(i, 1)) & "_" & CStr(arr(i, 2)) & "_" & CStr(arr(i, 3))

?????

????If Not dict.Exists(key) Then

??????dict(key) = True

????End If

??Next i

???

??Dim brr

??Dim j As Long

??Dim key1

??Dim 新行 As Long

???

??brr = Sheets("輔材表").UsedRange.Value

??新行 = 2

??Sheets("長攤表").UsedRange.Rows.Delete

??For j = LBound(brr, 1) + 1 To UBound(brr, 1)

????key1 = CStr(brr(j, 1)) & "_" & CStr(brr(j, 2)) & "_" & CStr(brr(j, 3))

?????

????If dict.Exists(key1) Then

??????'數(shù)據(jù)滿足條件,需要存到【長攤表】中

??????With Sheets("長攤表")

????????.Cells(新行, 1).Value = "'" & brr(j, 1)

????????.Cells(新行, 2).Value = "'" & brr(j, 2)

????????.Cells(新行, 3).Value = "'" & brr(j, 3)

??????End With

???????

??????新行 = 新行 + 1

????End If

??Next j

End Sub


'方法三

Sub 字典匹配數(shù)據(jù)_字典嵌套()

??Dim arr

??Dim i As Long

??Dim dict As Object

??Dim dict1 As Object

??Dim key As String

??Dim key1 As String

???

??arr = Sheets("長攤索引表").UsedRange.Value

??Set dict = CreateObject("Scripting.Dictionary")

???

??For i = LBound(arr, 1) + 1 To UBound(arr, 1)

????key = CStr(arr(i, 1))

?????

????If Not dict.Exists(key) Then

??????Set dict(key) = CreateObject("Scripting.Dictionary")

????End If

?????

????'Set dict1 = dict(key)

????key1 = CStr(arr(i, 2))

???????

????If Not dict(key).Exists(key1) Then

??????dict(key)(key1) = CStr(arr(i, 3))

????End If

??Next i

???

??Dim brr

??Dim j As Long

??Dim key2 As String

??Dim key3 As String

??Dim 新行 As Long

???

??brr = Sheets("輔材表").UsedRange.Value

??新行 = 2

??Sheets("長攤表").UsedRange.Rows.Delete

??For j = LBound(brr, 1) + 1 To UBound(brr, 1)

????key2 = CStr(brr(j, 1))

?????

????If dict.Exists(key2) Then

??????key3 = CStr(brr(j, 2))

???????

??????If dict(key2).Exists(key3) Then

????????If dict(key2)(key3) = CStr(brr(j, 3)) Then

??????????'數(shù)據(jù)滿足條件,需要存到【長攤表】中

??????????With Sheets("長攤表")

????????????.Cells(新行, 1).Value = "'" & brr(j, 1)

????????????.Cells(新行, 2).Value = "'" & brr(j, 2)

????????????.Cells(新行, 3).Value = "'" & brr(j, 3)

??????????End With

???????

??????????新行 = 新行 + 1

????????End If

??????End If

????End If

??Next j

End Sub

VBA——字典對象的常規(guī)用法和嵌套用法示例的評論 (共 條)

分享到微博請遵守國家法律
海口市| 漳州市| 镇宁| 岳阳市| 唐河县| 隆安县| 新邵县| 射洪县| 湘阴县| 顺昌县| 望城县| 湛江市| 华蓥市| 康定县| 宜宾市| 天等县| 大城县| 明溪县| 顺昌县| 大埔区| 昭觉县| 涞水县| 志丹县| 合山市| 岳普湖县| 乡宁县| 黎平县| 株洲市| 敦煌市| 凤凰县| 汉寿县| 依兰县| 错那县| 武陟县| 沧州市| 龙山县| 仪陇县| 呼伦贝尔市| 苏州市| 沙雅县| 汉川市|