VB Compiler doesn't appear to recognize ListRow type

jtyoder

New Member
Joined
Sep 13, 2017
Messages
2
For some reason, the VB compiler doesn't seem to be recognizing the ListRow type in my Subroutine. I've been developing the subroutine piece by piece, and it has been working fine, then, I started getting Compile error: "ByRef argument type mismatch" for a function call that was fine before. When I look at the function definition, the ListRow parameter being passed ByRef has been changed to "listRow" (lowercase L). Upon further examination, ListRow has been changed in the entire module. I don't know what I did that caused it. ListObject and ListColumns are fine, only ListRow is affected. If I change it back to ListRow, when I move the cursor off the definition, it gets changed back to listRow. Very strange.

This is the subroutine code I currently have. The affected declaration is the fourth Dim statement

Code:
Sub GenLatestVerRpt()
    Dim wsSrc, wsRpt As Worksheet
    Dim tblCDRLs, tblRpt As ListObject
    Dim srcCols, rptCols As ListColumns
    Dim srcRow, rptRow As listRow
    Dim currDRD, thisDRD As String
    Dim latestSub, latestAccpt As String: latestSub = "": latestAccpt = ""
    Set wsSrc = Worksheets("CDRLS - Full List")
    Set wsRpt = Worksheets("Latest Version Report")
    Set tblSrc = wsSrc.ListObjects("tblCDRLs")
    Set tblRpt = wsRpt.ListObjects("tblLatVerRpt")
    Set srcCols = tblSrc.ListColumns
    Set rptCols = tblRpt.ListColumns
    
    'Clear Existing Report
    If (tblRpt.ListRows.Count >= 1) Then
        tblRpt.DataBodyRange.Delete
    End If
    currDRD = tblSrc.ListRows(2).Range(1, srcCols("CDRL / DRD").Range.Column)
    
    If (isMulti(tblSrc.ListRows(2))) Then
        currDRD = currDRD & tblSrc.ListRows(i).Range(1, srcCols("EDN").Range.Column)
    End If
    
    For i = 2 To tblSrc.ListRows.Count
        srcRow = tblSrc.ListRows(i)
        If (isMulti(srcRow)) Then
            thisDRD = thisDRD & srcRow.Range(1, srcCols("EDN").Range.Column)
        Else
            thisDRD = srcRow.Range(1, 1)
        End If
        If (thisDRD = currDRD) Then
            If (isSubmitted(srcRow)) Then
                latestSub = getSubNum(srcRow)
            End If
            If (isDisp(srcRow)) Then
                latestDisp = getDisp(srcRow)
            End If
        Else
            'Found first entry of next DRD so insert current DRD row in report
            Set rptRow = tblRpt.ListRows.Add(AlwaysInsert:=True)
            rptRow.Range(1, rptCols("ID").Range.Column) = currDRD
            rptRow.Range(1, rptCols("Title").Range.Column) = srcRow.Range(1, srcCols("Title").Range.Column)
            rptRow.Range(1, rptCols("Latest Rev Submitted").Range.Column) = latestSub
            rptRow.Range(1, rptCols("Latest Rev Approved").Range.Column) = latestDisp
            currDRD = Left(thisDRD, 5) 'In case the EDN had been appended
        End If
    Next i
End Sub


Here is the Function that the compiler complains about
Code:
Function isMulti(ByRef rowToSrch As listRow)
    If (rowToSrch.Range(1, 35) = "Yes") Then
        isMulti = True
    Else
        isMulti = False
    End If
End Function

Thanks in advance for any help!
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
First, when you declare your variables like this...

Code:
Dim srcRow, rptRow As listRow

...you're declaring srcRow as Variant, not as ListRow. So, you'll need to declare it this way...

Code:
Dim srcRow As ListRow, rptRow As ListRow

Secondly, since you're assigning an object to your variable, you'll need to use the Set keyword. So, you'll need to replace...

Code:
srcRow = tblSrc.ListRows(i)

with

Code:
Set srcRow = tblSrc.ListRows(i)

Hope this helps!
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,327
Members
452,635
Latest member
laura12345

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