General discussion

  • Creator
    Topic
  • #2072884

    Handling an error in VBA/Excel

    Locked

    by jim_rau ·

    I just don’t see what I am missing an really need to get past this! I find error handling in VB Help but just when I think I have what I need and run it I cause Excel to stop responding. I need a complete answer here … after 4 hours I give up.

    I have a folder named C:\MyFolder and in it should be 10 files (named MyFile1.txt, MyFile2.txt, etc.). It is possible that some of the 10 are missing or too big.

    What is the VBA code that will open each file in turn and IF IT IS NOT IN THE FOLDER copy a sample file (named MyFile0.txt) with the name of the missing file (i.e. MyFile0.txt copied as MyFile3.txt)? If the file is there then it has to be less than 12KB or I need to copy the sample in place of the file as well (same MyFile0.txt).

    The code really has to work and to the person with the best solution … 1000 points! If the code does not fit you can e:mail it to me at jim_rau@prevos.com.

    Save me from this … please!!!

All Comments

  • Author
    Replies
    • #3782799

      Handling an error in VBA/Excel

      by syscokid ·

      In reply to Handling an error in VBA/Excel

      Can you email me your code to asyscokid@aol.com please? It would be easier to debug your code than start from scratch, plus give me a better idea of what you’re trying to do.

    • #3783426

      Handling an error in VBA/Excel

      by syscokid ·

      In reply to Handling an error in VBA/Excel

      Sorry, I’m not an ace programmer. I’ve done some VBA in Excel and Access as well as some VBScript but I learn best by copying examples, then trial and error (much like yourself, I guess). I’m still unsure exactly what you’re trying to do. hat’s why I say if I see some code I might be able to figure out where it’s going wrong.

      • #3767717

        Handling an error in VBA/Excel

        by jim_rau ·

        In reply to Handling an error in VBA/Excel

        I will have to post a better question for this issue of mine. Thanks for the thought …

    • #3766789

      Handling an error in VBA/Excel

      by kevin holden ·

      In reply to Handling an error in VBA/Excel

      I agree with the previous answer, not sure exactly what you are attempting. What is Excel trying to do with these files while VB is searching and copying. Also, which versions for Excel and VB are running???. I would also be interested in taking a look and would need the file to see what you are trying to do. Please email to SKEnt@bigfoot.com I do a lot with VB in Access and Excel and always like looking at what others are trying.

      Thanks

      • #3767718

        Handling an error in VBA/Excel

        by jim_rau ·

        In reply to Handling an error in VBA/Excel

        I will have to post a better question for this issue of mine. Thanks for the thought …

Viewing 2 reply threads