+ Reply to Thread
Results 1 to 9 of 9

Code error, highlight error, continue to RUN

  1. #1
    Registered User
    Join Date
    11-19-2007
    Posts
    85

    Code error, highlight error, continue to RUN

    Hello,


    For example if I run my code and there are errors and the reason for these error is b/c we import data, and data are not always the same, so if error do occurs,

    I would like the code to highlight the cells or rows where the error occurs to red, and not stop but still run the rest of the code.

    is this possible and show me some code that does this.

    thanks,

  2. #2
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591
    Hi

    What sort of errors? Errors that will break the code, or errors in the data construct?

    If the latter, can you give some sample data, reasons for the errors, how they can be determined, and what you want to do to highlight the errors.


    rylo

  3. #3
    Registered User
    Join Date
    11-19-2007
    Posts
    85
    I am not sure what you mean by
    Errors that will break
    the code means?

    but the kind of error I am talking about is, I built an application to run over and over for data that are unpredictable, but in general works for most data, especially the data that I use to test the applications to built it with.

    here are an example of error i have encounter for different datas that the old data works fine.

    in a phrase afeafeoulkalfeale8 ljeore 933r

    i have the code to run through this phrase, then when it encounters a number, what position is a number at, then i crave the words out from the beginning to the number.

    ie afeafeoulkalfeale

    so for all the data that i use to test, works b/c the numbers are after in 2,3,4 etc position but when the number appears in the first position, the code will gives an error.

    PHP Code: 
     space_or_nospace Mid(FullNameStart 11
    b/c the code i write doesn't applies to this data, this is just an example of the problems I've faced.

    but as discussed, if there are errors encounter, highlight the cells that is the problem and continue to run the code......... is this possible?

    the reason i do this is b/c i can't write a code that will solve all scenario that i may not know about, there can be many, you know what i mean?
    Last edited by JohnSeito; 05-06-2008 at 10:19 PM.

  4. #4
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591
    Hi

    By break, I mean that the code encounters something that it cannot handle, and goes into debug mode.

    I imagine you want to trap a particular error, and perform some action (ie highlight the item) when it encounters the problem.

    Can you give us a file with your code, some example data, what it is supposed to do, and what you want it to do when it encounters the problem.

    rylo

  5. #5
    Registered User
    Join Date
    11-19-2007
    Posts
    85
    By break, I mean that the code encounters something that it cannot handle, and goes into debug mode.
    this is the error I am talking about. my code is kinda complicated, if i explain it in details of what i want to do, i have to think about it and go through it and kinda write a huge essay.

    One little example out of the code is that--
    for example if i have a sentences all in one cell. i want my code to read this sentence, and crave out what i want from it base on conditions. for example in the sentences

    that is exactly what i am talking about, 189 is what i am talking about. Do you know what i mean.
    i want to see what position is when a number appears, in this case lets just say it appears in character 19, so what i do is, i would crave out the first part from the beginning to where the number is.

    that is exactly what i am talking about,

    and put this is a separate column. my code may work for this and many datas that you give it, but there are chances that it just won't work for certain data and gives error dubug issues. so whenever there are errors that is encounter, no matter what kind, just highlight that cells that is the problem for the errors, and continue on with other datas to work with.

    I don't want it to stop when there are no problems with other datas that the codes can work on, and i can't write codes that will work for all given conditions. I will solved those condition as i go on when i see them.

    so highlighting them would make me have the opportunity to see why is this error occurs and how i can tackle it for future, and also gives me the opportunity to do the highlighted ones manually since the codes can't do it.

    but these are rare, so for example out of 8 thousand datas, there will be two that are like this. and even when i solve this issue, other problems might occurs with other datas, i will solve it as i go along.


    PHP Code: 
    space_or_nospace Mid(FullNameStart 11
    start is 1 where the first letter will be readuntil the length of the sentencefullname is the whole sentencesthis code will crave what is in the middle of the sentences

  6. #6
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591
    Hi

    See if this gives you some ideas.

    In a new, test spreadsheet enter the values 1,0,3,0,4 in the range A3:A7.

    Then put the code
    Please Login or Register  to view this content.
    in a general module and run it. It should color the 0 entries, yet continue through the rest of the data.

    HTH

    rylo

  7. #7
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,953
    From your examples, you always stop at the first occurrance of a digit character. The code below will step through the contents of a cell and return that position:
    Please Login or Register  to view this content.
    You could insert a call to this fn and then process the result; for instance, the next code fragment, inserted after the fn-call, will format the cell in red if there are no digit characters found in the cell:

    Please Login or Register  to view this content.
    Ben Van Johnson

  8. #8
    Registered User
    Join Date
    11-19-2007
    Posts
    85
    Thanks protonLeah,


    Ok rylo, the code looks good, the only thing is that you have to know the error. I can avoid this only if there is a code that can knows it goes next, b/c when your code encounters an error, it goes to next.

    so is there a code that knows it goes next, if it does, then we can say.

    PHP Code: 
    if resume next then
          ce
    .Interior.ColorIndex 4
          Err
    .Clear
    end 
    if 
    this so it works for all errors.

    i noticed that the err.clear code is not needed and still works. i guess this code clears the error encounter.
    Last edited by JohnSeito; 05-07-2008 at 12:58 AM.

  9. #9
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591
    Hi

    It know it has met an error when the err.number is <> 0. I only used the divide by 0 to make an error. I've not used that error type specifically, just used it to make an error.

    rylo

+ Reply to Thread

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