Type Mismatch calling a function which requires a STRING, is sent a STRING and which returns a STRING...???

nigelandrewfoster

Well-known Member
Joined
May 27, 2009
Messages
747
Any suggestions? Error occurs at highlighted line. I'm stumped, I confess:

Code:
Function List_Open_Workbooks(lngPermitted As Long, ParamArray strSuffix() As Variant)    Dim wbOpen As Workbook
    Dim rngOpenWorkbooks As Range
    Dim strFilename As String
    Dim strWbSuffix As String
    Dim bytsuffix As Byte
    Dim blnSuffixAccepted As Boolean
    Dim blnCheckSuffix As Boolean
    
    frmWorkbookSelect.lstWorkbookSelector.MultiSelect = -(lngPermitted > 1)
    blnCheckSuffix = strSuffix(0) <> "*"
    
    With ThisWorkbook.Worksheets("Workpad")
        .[a2:a65535].Delete Shift:=xlUp
        
        For Each wbOpen In Workbooks
            If wbOpen.Name <> ThisWorkbook.Name Then
                If blnCheckSuffix Then
                    blnSuffixAccepted = False
[FONT=arial black]                    strWbSuffix = strSuffix(wbOpen.Name)[/FONT]
                    
                    For bytsuffix = 0 To UBound(strSuffix)
                        If strSuffix(bytsuffix) = strWbSuffix Then blnSuffixAccepted = True
                    Next
                Else
                    blnSuffixAccepted = True
                End If
                If blnSuffixAccepted Then .[a65535].End(xlUp).Offset(1).Value = wbOpen.Name
            End If
        Next
        
        frmWorkbookSelect.lstWorkbookSelector.RowSource = "Workpad!A2:" & .[a65535].End(xlUp).Address
    End With
    frmWorkbookSelect.Show


End Function


Function strSuffix(strFilename As String) As String
    Dim bytDot As Byte
    
    bytDot = InStrRev(strFilename, ".")
    If bytDot > 0 Then strSuffix = Right(strFilename, Len(strFilename) - bytDot)
End Function

Thanks!
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
strSuffix() is an array. You can't refer to items of an array by name, only by position.
 
Upvote 0
Got it. Thanks so much - I am calling a function which I have given the same name as the argument of the function calling it. Didn't spot it. Thanks so much for all your help.
 
Upvote 0

Forum statistics

Threads
1,215,477
Messages
6,125,030
Members
449,205
Latest member
Eggy66

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top