|
本帖最后由 NoooEnd 于 2023-3-19 14:06 编辑
- Function selectList(stage)
- Dim areaList As Object
- Set areaList = CreateObject("scripting.dictionary")
- Dim tier1, tier2
- Dim tier2s(), region
- Dim rowNum
- rowNum = ThisWorkbook.Worksheets(1).UsedRange.Rows.Count
- region = ThisWorkbook.Worksheets(1).Range("A2:D" & rowNum)
- Select Case stage
- Case "省"
- col = "1"
- Case "市"
- col = "2"
- Case "县"
- col = "3"
- End Select
- For i = 1 To UBound(region)
- tier1 = region(i, col)
- tier2 = region(i, col + 1)
- If Not areaList.exists(tier1) Then
- ReDim tier2s(1 To 1)
- tier2s(1) = tier2
- areaList.Add tier1, tier2s()
- Else
- tier2s() = areaList(tier1)
- If UBound(VBA.Filter(tier2s(), tier2)) < 0 Then
- qty = UBound(tier2s())
- ReDim Preserve tier2s(1 To qty + 1)
- tier2s(qty + 1) = tier2
- areaList(tier1) = tier2s()
- End If
- End If
- Erase tier2s()
- Next
- Set selectList = areaList
- End Function
复制代码
|
评分
-
3
查看全部评分
-
|