我似乎无法找到解释如何在VBA中创建哈希表或关联数组的文档.它甚至可能吗?
你可以链接到一篇文章或更好地发布代码吗?
我正在使用VBA并且需要以type key=> 保存数据value以获得最快速度; 这种数据类型帮我从http请求缓存responese文本,提高查询速度.但我不知道最好的方法是什么?我需要一个与php数组相同的数据类型key=>value!谢谢你的帮助!
我在Access应用程序中使用VBA,我想有一个包含不同数据类型值的n元组对象.然后我想要这些对象的集合.
如果我在javascript中这样做,它看起来像:
var myStructure = {
name: "blah"
age: 33
moreStuff : "test"
};
Run Code Online (Sandbox Code Playgroud)
然后我需要一个myStructure的集合.我怎样才能在VBA中做到最好?
出于某些技术原因,我们不能在单词中使用样式.为了加快反复应用全局属性,我创建了一个可以从简单的xml样式表中读取的类.该表包含不同的"段落".每个段落只存储我们最常使用的段落属性.
我习惯使用C++,我可以使用动态内存,而我正在尝试复制动态分配的数组的行为.但是,当我尝试重新调暗时,我收到错误消息"Array arleady dimensioned".
我对MSDN的研究表明,为了ReDim,数组必须是Global或者是"一般声明上下文".这让我觉得它可能根本无法在类中完成.
摘自MSDN:
"您只能在过程级别使用ReDim.因此,变量的声明上下文必须是一个过程;它不能是源文件,命名空间,接口,类,结构,模块或块".
我试图搜索堆栈溢出"Word VBA Array已经标注尺寸",并且无法获得所有3页结果.
private type pStyle 'Definition removed because it's not needed
private Paragraphs(0) As pStyle 'Initially an empty array of paragraphs
Run Code Online (Sandbox Code Playgroud)
后来我有以下功能
Public Function AddEmpty()
'Create space
count = count + 1
ReDim Preserve Paragraphs(count)
AddEmpty = count
End Function
Run Code Online (Sandbox Code Playgroud)
如果有任何想法,请告诉我.我宁愿不必"估计"每个样式表所需的段落样式的数量,因为每个文件都不同.
我在col A中有一个完整的不同路径列表.我有一个B和C的详细列表.
如何在新工作表上:1)拉出每个唯一路径,2)为每个路径编译B*C中的值并删除重复项.3)在最新一行完成后重复下一个路径.
我确实有一个错误的宏,但为了简洁和准确,我不会发布.除非有人想阅读,否则请求
任何帮助将不胜感激.
这就是我所拥有的(我理解它的长期,我会尝试清理它):
Sub FileDetail()
'Does not fill down, go to bottom to unleased fill down
'Skips unreadable files
'This Macro retrieves data from files picked. The data is based on header. Data is also filtered for unique values.
'You must make sure headers are in the first row and delimted.
Dim wb As Workbook, fileNames As Object, errCheck As Boolean
Dim ws As Worksheet, wks As Worksheet, wksSummary As Worksheet
Dim y As Range, intRow As …Run Code Online (Sandbox Code Playgroud) 鉴于我有以下内容
<Sheet 1>
Item QTY
A 5
B 1
C 3
<Sheet 2>
Item QTY
A 15
B 4
C 1
D 8
Run Code Online (Sandbox Code Playgroud)
生成显示工作表1和2之间差异的报告的最佳方法是什么?
喜欢
<Difference>
Item QTY
A 10
B 3
C -2
D 8
Run Code Online (Sandbox Code Playgroud) 我正在努力使我的Dictionary对象工作以返回所选参考编号的经济细节.
例如,我有以下参考号和相应的值,但是,不确定我是否可以使用Dictionary对象实现这一点,并且备选的建议将受到高度赞赏.
Ref No Amount Price Year
IB1232 1000 1.23 2011
IB1231 1000 3.23 2011
IB1233 1000 3.43 2011
IB1234 1000 3.43 2011
Run Code Online (Sandbox Code Playgroud)
我认为可以通过形成Key和Value来实现参考及其相应的细节,但是无法实现..
在我的代码中我想使用if条件.我想在其中使用"OR"约18次.喜欢例如
If a="something" or a="something" or a="something" or.........(up to 18 times)... then
'do nothing
else
'do action
end if
Run Code Online (Sandbox Code Playgroud)
[注:值一个正在改变For循环每次],所以我只想问确实有使用或有限次,如果有任何的限制.或者还有其他更好的方法来做同样的事情.
谢谢
我试图将数据保存在类模块中声明的字典中.我在类模块中使用了字典,因为组的数量和关联的数据点在开始时是未知的.下面的代码编译,但dRATIO.exists模块和类模块中的语句都返回false(但是在第一次传递时,类模块中的debug语句给出了正确的值,之后出现错误),然后Function GetRATIO返回999.有什么建议吗?
'CODE IN A CLASS MODULE CALLED clsIVDATA
Option Explicit
Public dRATIO
Public dIV
'
Sub Init(RATIO As Variant, IV As Variant, KEY As String)
'Dim I As Long
Dim VAL As String
Dim RowKeys
Dim COLKEYS
Set dRATIO = CreateObject("Scripting.Dictionary")
Set dIV = CreateObject("Scripting.Dictionary")
dRATIO.ADD ITEM:=RATIO, KEY:=KEY
dIV.ADD ITEM:=RATIO, KEY:=KEY
Debug.Print dRATIO.Exists("1")
Debug.Print dRATIO.ITEM("1")
End Sub
Function GetRATIO(KEY As String)
If dRATIO.Exists(KEY) Then
GetRATIO = dRATIO(KEY)
Else
GetRATIO = 999 'or raise …Run Code Online (Sandbox Code Playgroud) 我想将项目列表添加到集合中并避免添加重复项。这是我在 A 列中的列表
Apple
Orange
Pear
Orange
Orange
Apple
Carrot
Run Code Online (Sandbox Code Playgroud)
我只想添加
Apple
Orange
Pear
Carrot
Run Code Online (Sandbox Code Playgroud)
这是我想出的方法,它有效,但并不漂亮。
dim coll as New Collection
ln = Cells(Rows.Count, 1).End(xlUp).Row
coll.Add (Cells(1, 1).Value) 'Add first item manually to get it started
For i = 1 To ln
addItem = True 'Assume it's going to be added until proven otherwise
For j = 1 To coll.Count 'Loop through the collection
'If we ever find the item in the collection
If InStr(1, Cells(i, 1), coll(j), vbTextCompare) > …Run Code Online (Sandbox Code Playgroud)