arrays - 具有复合键字典的 VBA 数组代码
问题描述
我试图将大型 excel 数据循环到字典中并拉出。这是我正在尝试的代码我遇到了很多错误。请帮我写下我的代码~!!
Sub Me()
Dim dict As Object
Set dict = CreateObject("Scripting.Dictionary")
Set ws1 = Sheets("Sheet1")
lastrow = ws1.Range("B" & ws1.Rows.Count).End(xlUp).Row
LastCol = ws1.Cells(Range("C2").Row, ws1.Columns.Count).End(xlToLeft).Column - 1
vd = WorksheetFunction.Transpose(WorksheetFunction.Transpose(ws1.Range("C3").Resize(1, LastCol - 1)))
va = ws1.Range("b4").Resize(lastrow - 2, 1)
For i = LBound(va) To UBound(va)
dict.Add addToString(vd(1), va(i, 1)), ws1.Cells(i + 3, 3).Value
Debug.Print dict("uniqueXXXuniqueYYY")
Next i
End Sub
Public Function addToString(ParamArray myVar() As Variant) As String
Dim cnt As Long
Dim val As Variant
Dim delim As String: delim = "unique"
For cnt = LBound(myVar) To UBound(myVar)
addToString = addToString & delim & myVar(cnt)
Next cnt
End Function
解决方案
推荐阅读
- reactjs - 带有 ReactJS 的 Slick Slider 上的活动点类
- java - Apache Camel 组件的版本兼容性
- android - 带有下拉列表图标的材质微调器
- html - 如何使用纯 JavaScript 创建 Material Icon
- discord.js - 如何将 Windy API 添加到 discord-js 机器人?
- typescript - 如何使用 Jest 监控 ES6 方法调用?
- rust - 为什么有时似乎允许在涉及 += 运算符的同一表达式中使用可变引用和不可变引用,有时则不允许?
- vuejs3 - 如何配置 Vite 为生产版本创建特定的启动文件夹
- flutter - 'Null' 不是 '(String, dynamic) => void' of 'f' 类型的子类型)
- webpack - Webpack 的确定性模块 ids 优化