+ Reply to Thread
Results 1 to 2 of 2

On Error not tripping every time

  1. #1
    Registered User
    Join Date
    08-12-2013
    Location
    Kansas City
    MS-Off Ver
    Excel 2010
    Posts
    1

    On Error not tripping every time

    Need some help understanding how I can get my OnError to work every time. I am looping through a labor report that is poorly formatted so I'm using the find functionality in Excel. If a name doesn't exist I'm (Error 91) I'm telling it to put 0s in the hours then goto the next name in the list. It works on the first name but not on the second. Here is some of the code. First time posting so please be gentle. Thank you!

    On Error GoTo NoName
    If a = 1 Then
    Cells.Select
    Selection.Find(What:=stremployee, After:=ActiveCell, LookIn _
    :=xlValues, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:= _
    xlNext, MatchCase:=False, SearchFormat:=False).Activate
    lngrow = ActiveCell.Row
    Else

    Range("A" & lngEndRow - 5).Select
    Cells.Find(What:=stremployee, After:=ActiveCell, LookIn:=xlValues _
    , LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
    MatchCase:=False, SearchFormat:=False).Activate
    lngrow = ActiveCell.Row
    End If

    More code...

    NoName:
    Sheets("Summary").Activate
    Cells(lngActRow, 4) = dbltotreg
    Cells(lngActRow, 5) = dblot
    Cells(lngActRow, 6) = dbldt
    Range("A1").Select
    dbltotreg = 0
    dblot = 0
    dbldt = 0
    a = a + 1
    Next cell

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: On Error not tripping every time

    How about not using On Error?
    Please Login or Register  to view this content.
    PS Can you use code tags when posting code?
    If posting code please use code tags, see here.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 7
    Last Post: 05-15-2013, 09:02 AM
  2. run-time error ;2147023179 (800706b5) time automation error interface unknown
    By karthik72 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-02-2012, 09:31 AM
  3. Error "run-time Error '1004': General Odbc Error
    By D4WNO77 in forum Access Tables & Databases
    Replies: 2
    Last Post: 07-16-2012, 09:55 AM
  4. Excel Macro Error - Run time error 1004 - Paste method of worksheet class failed
    By kvflynn in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-15-2012, 10:51 AM
  5. [SOLVED] run-time error '1004': Application-defined or object-deifined error
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-10-2005, 05:05 PM

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