tiredofit
Well-known Member
- Joined
- Apr 11, 2013
- Messages
- 1,924
- Office Version
- 365
- 2019
- Platform
- Windows
The code below work in early binding:
but when I convert it to late binding, it fails here:
What do I have to do to fix it?
Thanks
Code:
Dim DIC As Scripting.Dictionary
'Dim DIC As Object
Set DIC = New Scripting.Dictionary
'Set DIC = CreateObject("Scripting.Dictionary")
Dim MyArray() As Variant
MyArray() = Sheet1.Cells(1, 1).CurrentRegion.Value
Dim n As Long
For n = 1 To UBound(MyArray(), 1)
DIC.Item(MyArray(n, 1)) = 0
Next n
Dim KeysArray() As Variant
KeysArray() = DIC.Keys
Dim NumKeys As Long
NumKeys = DIC.Count
Dim ElementsArray() As Variant
ReDim ElementsArray(1 To DIC.Count, 1 To 1) As Variant
Dim DataRng As Range
Set DataRng = Sheet1.Range(Sheet1.Cells(2, 1), Sheet1.Cells(Module1.LRow(wks:=Sheet1), 1))
Dim Counter As Long
For Counter = 1 To DIC.Count - 1
ElementsArray(Counter + 1, 1) = Application.WorksheetFunction.CountIf(DataRng, DIC.Keys(Counter))
Next Counter
but when I convert it to late binding, it fails here:
Code:
ElementsArray(Counter + 1, 1) = Application.WorksheetFunction.CountIf(DataRng, DIC.Keys(Counter)
What do I have to do to fix it?
Thanks