I'm not understanding what the problem is.
I have the following code:
Public Sub SetupForm()
Dim wbMain As Workbook
Dim wsToner As Worksheet
Set wbMain = ActiveWorkbook
Set wsToner = wbMain.Sheets("Toner")
With DashboardForm
'Parent nodes
Dim Brands() As String
Brands() = GetTonerBrand(wsToner)
The last line is calling the following function:
Private Function GetTonerBrand(wsSheet As Worksheet) As String
Dim col, Counter
Dim LastCol
Counter = 0
Dim LastRow
Dim Brands() As String
With wsSheet
LastRow = .Cells(.Rows.Count, 2).End(xlUp).Row
Dim RowCount
RowCount = LastRow
End With
Dim dict
Set dict = CreateObject("Scripting.Dictionary")
Do While RowCount > 3
If Not dict.exists(wsToner.Cells(RowCount, 2).Value) Then
dict.Add wsToner.Cells(RowCount, 2).Value, 0
End If
RowCount = RowCount - 1
Loop
ReDim Brands(0 To dict.Count)
Brands() = dict.keys()
GetTonerBrand Brands
End Function
When I attempt to run this I get the error below:
Compile error: ByRef argument type mismatch
I thought that if I update the type of the array and function then it would work.
So I changed the Function to String and the Brands() arrays as well were changed to String. Then I get an error:
Compile error: Can't assign to array
in the SetupForm
sub on the line Brands() = GetTonerBrand(wsToner)
Obviouly I'm missing something, I just don't see what it is.
UPDATE
I have seen this other question with a similar name, it isn't helpful.