Name

listrow.InvalidData

Synopsis

Returns True if the row contains data that is not valid as per the list schema. Returns False if the row contains only valid data. The following code highlights rows in lists that contain invalid data:

Sub HighlightInvalidRows(  )
    Dim ws As Worksheet, lst As ListObject, row As ListRow
    Set ws = ActiveSheet
    Set lst = ws.ListObjects("Test List")
    For Each row In lst.ListRows
        If row.InvalidData Then
             row.Range.Font.Color = RGB(255, 0, 0)
        Else
            row.Range.Font.Color = RGB(0, 0, 0)
        End If
    Next
End Sub

Excel validates list entries as the user enters data, so it is unlikely that invalid data is the result of user edits. However, entries made by code are not automatically validated.

Get Programming Excel with VBA and .NET now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.