Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Macos 字典词典-vba Office for Mac_Macos_Excel_Dictionary_Vba - Fatal编程技术网

Macos 字典词典-vba Office for Mac

Macos 字典词典-vba Office for Mac,macos,excel,dictionary,vba,Macos,Excel,Dictionary,Vba,简而言之,我们从一个应用程序(而不是我们自己的应用程序)中获取excel报告,该应用程序将来自单个表单的所有用户响应放入每个提交的单个单元格中。我正在尝试为Office:mac Excel编写VBA宏 因此,“修改器”列中的单个单元格可能如下所示: 单元格1: 第一任教师选择|冈德森;第二任教师选择|巴恩斯;你喜欢果冻吗;超人还是绿巨人?|绿巨人 单元格2: 第一任教师选择|史密斯;第二任教师选择|冈德森;你喜欢果冻吗?|喜欢 单元格3: 第一任教师选择|伍尔芬巴赫;第二教师选择|丰塔纳;你喜欢

简而言之,我们从一个应用程序(而不是我们自己的应用程序)中获取excel报告,该应用程序将来自单个表单的所有用户响应放入每个提交的单个单元格中。我正在尝试为Office:mac Excel编写VBA宏

因此,“修改器”列中的单个单元格可能如下所示:

单元格1: 第一任教师选择|冈德森;第二任教师选择|巴恩斯;你喜欢果冻吗;超人还是绿巨人?|绿巨人

单元格2: 第一任教师选择|史密斯;第二任教师选择|冈德森;你喜欢果冻吗?|喜欢

单元格3: 第一任教师选择|伍尔芬巴赫;第二教师选择|丰塔纳;你喜欢果冻吗?|不喜欢;超人还是绿巨人?|超人

单元格4: 第一教师选择|丰塔纳;第二任教师选择|史密斯;你喜欢果冻吗;超人还是绿巨人?|超人

单元格5: 第一教师选择|外差;第二任教师选择|伍尔芬巴克;你喜欢果冻吗;超人还是绿巨人?|超人

我的目标是收集所有问题(在;和|之间的文本),为每个问题创建一列,然后用答案填充这些列。我将哈希表设想为:

{
 "1st Teacher Choice":{1:"Gunderson", 2:"Smith", 3:"Wulfenbach", 4:"Fontana", 5:"Hetrodyne"},
 "2nd Teacher Choice":{1:"Barnes", 2:"Gunderson", 3:"Fontana", 4:"Smith", 5:"Wulfenbach"},
 "Do you like Jello?":{1:"yes", 2:"yes", 3:"no", 4:"yes", 5:"yes"},
 "Superman or Hulk":{1:"Hulk", 2:"",3:"Superman",4:"Superman",5:"Superman"}
}
现在,在所有的序言之后,这里是我试图开始工作的代码:

Dim modifierColumn As Integer
Dim rawModifiers As String
Dim oneMod As String
Dim oneResp As String

Dim modifierList As Dictionary
Set modifierList = New Dictionary

For theRow = 2 To lastRow
    'Get the string of modifiers in the current row
    rawModifiers = Cells(theRow, modifierColumn).value
    'Break each modifier string in the row into a separate array element
    rowModifiersArray = Split(rawModifiers, ";")
    'Iterate through each of the modifiers and value in the new array
    For Each modResp In rowModifiersArray
        'Seperate the modifier from the response in another temp array, 'singleModifier’.
        'The first element of the array will be the name of the modifier, the second will be the response to the modifier.
        singleModifier = Split(modResp, "|")
        oneMod = singleModifier(0)
        oneResp = singleModifier(1)
        'If the modifier exists as a key in the ModifierList, add the row and the value into the dictionary associated to that key
        'If the modifier has already been entered in modifierList, add the row and value to the sub-dictionary
        If (Not modifierList.Exists(oneMod)) Then
            modifierList.Add oneMod, New Dictionary
        End If
        'ERROR IS THROWN ON LINE BELOW
        modifierList(oneMod).Add theRow, oneResp
    Next
Next theRow
上面的代码仅创建哈希表。在这之后创建专栏非常简单,因此出于这个问题的目的,我将省略它


我已经安装了Patrick O'Bierne在上创建的外接程序字典键值类。但是,在底部的第三行,我得到一个运行时错误('438'),声明“Object不支持此属性或方法”,并用注释标记。第一个Dictionary.Add方法运行良好。有什么想法吗?这可能是类实现中的错误吗?

似乎需要更明确一点

而不是

modifierList(oneMod).Add theRow, oneResp
试试这个

modifierList.KeyValuePairs(oneMod).value.Add theRow, oneResp

就这样!虽然字典显然要求你的索引不是整数(糟糕!),但我不得不稍微调整一下你的答案:
modifierList.KeyValuePairs(oneMod.value.Add-CStr(theRow),oneResp