Results 1 to 5 of 5

Complile Error: Type Mismatch ??? After adding error trap

Threaded View

  1. #1
    Forum Contributor
    Join Date
    12-20-2011
    Location
    United States, Ohio
    MS-Off Ver
    Excel 2010
    Posts
    295

    Question Complile Error: Type Mismatch ??? After adding error trap

    So this was my code and it worked just fine.

    Private Sub ShowOnlyRowsThatAreTrue()   'This shows only the rows that are to be included
    'in the systems included section
        Application.ScreenUpdating = False
        Dim FirstSystems_Row As Long
        Dim n As Integer
        Dim i As Integer
        
        FirstSystems_Row = Cells.Find("Systems included in this proposal are as follows:", , xlValues, xlWhole).Offset(2).Row
            For i = 5 To 23
                If Sheet1.OLEObjects("CheckBox" & i).Object.Value = True Then
                    Sheet5.Rows(FirstSystems_Row).EntireRow.Hidden = False
                End If
                FirstSystems_Row = FirstSystems_Row + 1
            Next i
    Application.ScreenUpdating = True
    End Sub

    I wanted to error trap for when the find command doesnt find anything - so I changed my code to this and now it doesnt work. I get an COMPLILE ERROR: TYPE MISMATCH. What does that mean?
    Private Sub ShowOnlyRowsThatAreTrue()   'This shows only the rows that are to be included
    'in the systems included section
        Application.ScreenUpdating = False
        Dim FirstSystems_Row As Long
        Dim n As Integer
        Dim i As Integer
        
        FirstSystems_Row = Cells.Find("Systems included in this proposal are as follows:", , xlValues, xlWhole).Offset(2).Row
        If Not FirstSystems_Row Is Nothing Then
            For i = 5 To 23
                If Sheet1.OLEObjects("CheckBox" & i).Object.Value = True Then
                    Sheet5.Rows(FirstSystems_Row).EntireRow.Hidden = False
                End If
                FirstSystems_Row = FirstSystems_Row + 1
            Next i
        Else
           Msgbox "ERROR! Systems included in this proposal are as follows: Text is not found on the cover letter."
           Application.ScreenUpdating = True
        End If
    End Sub
    All I changed was:
    If Not FirstSystems_Row Is Nothing Then
    'code
    Else
       Msgbox "ERROR! Systems included in this proposal are as follows: Text is not found on the cover letter."
    
    End If
    Last edited by clemsoncooz; 02-22-2012 at 03:50 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1