+ Reply to Thread
Results 1 to 2 of 2

Error handling within a Do Loop

  1. #1
    Registered User
    Join Date
    04-30-2012
    Location
    Huntington Beach, Ca
    MS-Off Ver
    Excel 2003
    Posts
    1

    Unhappy Error handling within a Do Loop

    I'm comparing two list of numbers on two different sheets to see which numbers have been omitted from one of the lists. I'm trying to use a Find statement with error trapping within a Do Loop to capture the missing numbers within a text string. The code works fine for detecting and capturing the first missing number, but when the second error occurs I just get the "Object variable or With block variable not set (Error 91)" error message. Is there something I have to do to "reset" the error handling? I tried err.clear but that doesn't seem to work. My code is below...

    Please Login or Register  to view this content.
    Last edited by arlu1201; 05-01-2012 at 02:31 AM. Reason: Put code tags in future.

  2. #2
    Forum Contributor
    Join Date
    03-21-2012
    Location
    Ho Chi Minh city
    MS-Off Ver
    Excel 2003
    Posts
    180

    Re: Hope this help!

    PHP Code: 
    Option Explicit
    Sub ComperingColumnsInSheets
    ()
     
    Dim Sh As WorksheetRng As RangesRng As RangeCls As Range
     
     Set Sh 
    ThisWorkbook.Worksheets("End Day")     '<=|'
     
    Set Rng Sh.Range(Sh.[a6], Sh.[a6].End(xlDown))
     
    Sheets("Start Day").Select
     
    For Each Cls In Range([a2], [a2].End(xlDown))     '<=|'
        
    Set sRng Rng.Find(Cls.Value, , xlFormulasxlWhole)
        If 
    sRng Is Nothing Then
            Cls
    .Offset(, 4).Value "Nothing"
        
    Else
            
    Cls.Offset(, 4).Value "Row: " sRng.Row
        End 
    If
     
    Next Cls
    End Sub 

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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