enzovitale
New Member
- Joined
- Jun 27, 2011
- Messages
- 3
Dear all,
I need to get a list of all formula arrays in the current sheet. I'd like to do this in VBA.
It would be very nice if Microsoft provided an 'Arrays' property of the Workbook and Worksheet objects, like they do for e.g. the 'Names' collection. Then, I could just query this property.
Since to my knowledge they don't, I wrote the code below, which works nicely but is quite SLOW. Any suggestions?
Enzo
Dim UsedRange As Excel.Range
Set UsedRange = ActiveSheet.UsedRange
Dim DictionaryArrays As Scripting.Dictionary
Set DictionaryArrays = New Scripting.Dictionary
' Build up a collection of all distinct array ranges
' by looping over all cells in the used range.
If Not UsedRange.HasArray = False Then
For Each iCell In UsedRange
If iCell.HasArray Then
Set iArray = iCell.CurrentArray
If Not DictionaryArrays.Exists(iArray.Address) Then
Call DictionaryArrays.Add(iArray.Address, iArray)
End If
End If
Next
End If
I need to get a list of all formula arrays in the current sheet. I'd like to do this in VBA.
It would be very nice if Microsoft provided an 'Arrays' property of the Workbook and Worksheet objects, like they do for e.g. the 'Names' collection. Then, I could just query this property.
Since to my knowledge they don't, I wrote the code below, which works nicely but is quite SLOW. Any suggestions?
Enzo
Dim UsedRange As Excel.Range
Set UsedRange = ActiveSheet.UsedRange
Dim DictionaryArrays As Scripting.Dictionary
Set DictionaryArrays = New Scripting.Dictionary
' Build up a collection of all distinct array ranges
' by looping over all cells in the used range.
If Not UsedRange.HasArray = False Then
For Each iCell In UsedRange
If iCell.HasArray Then
Set iArray = iCell.CurrentArray
If Not DictionaryArrays.Exists(iArray.Address) Then
Call DictionaryArrays.Add(iArray.Address, iArray)
End If
End If
Next
End If