2
我想取消组合并重新组合我存储在数组中的一系列组。但是,当我运行它时,出现以下错误:'范围类失败的取消组合方法'错误
Run-time error '1004':
Ungroup method of Range class failed
我的代码如下。 xxxDim
变量用于识别数组是否存在。我以前正确识别所有sSub
,eSub
,sGroup
,eGroup
,sCat
和eCat
变量,因此实际值是关注的不是。我已经使用所指的确切范围手动完成了取消组合和重新组合,所以我不相信我指的是一个范围,它很难找出解组/分组。
我已经使用这个格式(.Range("A" & variable & ":A" & variable).ungroup
)之前没有问题取消分组和分组的方法。
''''' START WITH UNGROUPING EVERYTHING '''''
''''' SUB-MODELS '''''
If sSubDim = True Then 'This Array has been dimensioned and therefore has at least one entry
For i = LBound(sSub) To UBound(sSub)
.Range("A" & sSub(i) & ":A" & eSub(i)).Ungroup 'Receive error on this line first
Next
End If
''''' GROUPS '''''
If sGroupDim = True Then 'Multiple groups exist
For i = LBound(sGroup) To UBound(sGroup)
.Range("A" & sGroup(i) & ":A" & eGroup(i)).Ungroup
Next
End If
''''' CATEGORY '''''
.Range("A" & sCat & ":A" & eCat).Ungroup
''''' NOW GROUP EVERYTHING '''''
''''' SUB-MODELS '''''
If sSubDim = True Then 'This Array has been dimensioned and therefore has at least one entry
For i = LBound(sSub) To UBound(sSub)
.Range("A" & sSub(i) & ":A" & eSub(i)).Group
Next
End If
''''' GROUPS '''''
If sGroupDim = True Then 'Multiple groups exist
For i = LBound(sGroup) To UBound(sGroup)
.Range("A" & sGroup(i) & ":A" & eGroup(i)).Group
Next
End If
''''' CATEGORY '''''
.Range("A" & sCat & ":A" & eCat).Group
我所有的团体我拆组已经肯定分组。我最终将'.Range(“A”&variable&“:A”&variable).ungroup'更改为'.Rows(variable&“:”&variable).ungroup',它解决了我的问题。不知道为什么以前的范围适用于我使用它的部分,而不是在这里。 – cheshire
如果他们已经分组,那么他们将不会大惊小怪。如果你在非分组范围内调用'.Ungroup',你会得到完全错误的结果。验证你的输入。 –
有趣的答案,顺便说它适用于我。 thx @ Mat'sMug – neverwinter