+ Reply to Thread
Results 1 to 27 of 27

Looping Problem

  1. #1
    Registered User
    Join Date
    07-07-2011
    Location
    Mumbai
    MS-Off Ver
    Excel 2003
    Posts
    36

    Looping Problem

    hi...

    i use the following code to update some files.

    Please Login or Register  to view this content.
    When it reaches the last row, it keeps on looping.
    i want it to stop after the last row is done......

    Please help...

    Thanks






    Additional details:-

    the cell values in the first column are the names of the files stored on my hard disk,
    if a file is not present on my hard disk for upgradation, it will give error...
    hence i m forced on using the error handler,
    but its messing up the loop.

    Plz help
    Last edited by Spasm; 07-09-2011 at 02:29 PM.

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Looping Problem

    Hello Spasm,

    Here is your macro with a few revisions.
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Registered User
    Join Date
    07-07-2011
    Location
    Mumbai
    MS-Off Ver
    Excel 2003
    Posts
    36

    Re: Looping Problem

    hi....
    thank u for helping me with the code
    but it gives an error at
    Please Login or Register  to view this content.
    ( 3rd line from bottom )

  4. #4
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: Looping Problem

    Does the following work?
    Please Login or Register  to view this content.
    This was not tested except for at compile time. I really don't know if it will do what you want at run-time. I was just playing with your code.
    If you're happy with someone's help, click that little star at the bottom left of their post to give them Reps.

    ---Keep on Coding in the Free World---

  5. #5
    Registered User
    Join Date
    07-07-2011
    Location
    Mumbai
    MS-Off Ver
    Excel 2003
    Posts
    36

    Re: Looping Problem

    thank U for ur effort
    but the code has some problems
    i tried it....
    it keeps on looping on the 2nd row... it does not increment,, and it also keeps on prompting to save the file...

  6. #6
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: Looping Problem

    Maybe:
    Please Login or Register  to view this content.
    Last edited by Mordred; 07-08-2011 at 10:45 PM.

  7. #7
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Looping Problem

    Hello Spasm,

    Sorry, I forgot to exit when the cell is empty. Try this instead...
    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    07-07-2011
    Location
    Mumbai
    MS-Off Ver
    Excel 2003
    Posts
    36

    Re: Looping Problem

    thanks ......
    Last edited by Spasm; 07-08-2011 at 11:02 PM.

  9. #9
    Registered User
    Join Date
    07-07-2011
    Location
    Mumbai
    MS-Off Ver
    Excel 2003
    Posts
    36

    Re: Looping Problem

    thanks

  10. #10
    Registered User
    Join Date
    07-07-2011
    Location
    Mumbai
    MS-Off Ver
    Excel 2003
    Posts
    36

    Re: Looping Problem

    hi Leith Ross
    i tried the second code
    but it didnt run at all


    thank u for ur effort n time

  11. #11
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Looping Problem

    Hello Spasm,

    I can not help you further on this problem because I have no idea what you are doing on your end that is causing the code to fail. The code works on my machine and I am running Excel 2003 under Windows XP. Perhaps, you will figure it out in time.

  12. #12
    Registered User
    Join Date
    07-07-2011
    Location
    Mumbai
    MS-Off Ver
    Excel 2003
    Posts
    36

    Re: Looping Problem

    hi Mordred
    i tried ur second code
    it increments but always prompts to save the file
    and when an error occurs,,, it stops incrementing and auto closes itself

    thanks for ur effort

  13. #13
    Registered User
    Join Date
    07-07-2011
    Location
    Mumbai
    MS-Off Ver
    Excel 2003
    Posts
    36

    Re: Looping Problem

    its ok


    i m sorry for not providing enough information about my problem

    thanks for your time and effort
    Last edited by Spasm; 07-09-2011 at 06:47 AM.

  14. #14
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Looping Problem

    This is a duplicate post and as such does not comply with Rule 5 of our forum rules. This thread will now be closed, you may continue in your other thread.

    Thread Closed.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  15. #15
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Looping Problem

    Hmm?
    We seem to be in a bit of a mess here!

    Is this thread closed or not?
    The duplicate certainly is and that's where I posted a solution that works for me!

  16. #16
    Registered User
    Join Date
    07-07-2011
    Location
    Mumbai
    MS-Off Ver
    Excel 2003
    Posts
    36

    Re: Looping Problem

    ok
    thanks

  17. #17
    Registered User
    Join Date
    07-07-2011
    Location
    Mumbai
    MS-Off Ver
    Excel 2003
    Posts
    36

    Re: Looping Problem

    2 files for my code problem
    Attached Files Attached Files

  18. #18
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: Looping Problem

    I added one line of code to your existing code from post 1, will it work? Maybe.
    Please Login or Register  to view this content.
    I added
    Please Login or Register  to view this content.

  19. #19
    Registered User
    Join Date
    07-07-2011
    Location
    Mumbai
    MS-Off Ver
    Excel 2003
    Posts
    36

    Re: Looping Problem

    ur code did everything perfectly as i wanted
    but once the last row was done
    it kept on looping until row 65536
    Last edited by Spasm; 07-09-2011 at 02:01 PM.

  20. #20
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Looping Problem

    At a glance, you need an Exit Sub statement after the Loop statement.
    Entia non sunt multiplicanda sine necessitate

  21. #21
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: Looping Problem

    Have you tried the code that I provided in post #18? shg is no doubt right so maybe instead of
    Please Login or Register  to view this content.
    you should have
    Please Login or Register  to view this content.

  22. #22
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: Looping Problem

    It could be
    Please Login or Register  to view this content.
    that is causing the most problems, specifically
    Please Login or Register  to view this content.
    which puts you right back into the loop.

  23. #23
    Registered User
    Join Date
    07-07-2011
    Location
    Mumbai
    MS-Off Ver
    Excel 2003
    Posts
    36

    Re: Looping Problem

    yesssssssssss yaaaaaayyyy,,
    i added EXIT SUB after the loop, and the macro worked perfectly fine.. did everything perfectly and didnt kept on looping after the last row

    thank U Mordred
    &
    thank u SHG

    for your amazing help and for giving ur precious time to solve my problem

    thank u ALL

  24. #24
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: Looping Problem

    We are glad to help. If you feel that your problem has been solved, mark this thread as solved and, if you are happy with the help you have received, don't be shy and tap the scales of those that helped.

    Cheers

  25. #25
    Registered User
    Join Date
    07-07-2011
    Location
    Mumbai
    MS-Off Ver
    Excel 2003
    Posts
    36

    Re: Looping Problem

    yes .... added reputation for both of u

  26. #26
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Looping Problem

    The solution I offered in your closed duplicate thread works, and solves other problems that might arrise.

    You PMd me to say it doesn't work, I can't see why this should be the case, but if your happy, so am I.
    If you need any more information, please feel free to ask.

    However,If this takes care of your needs, please select Thread Tools from menu above and set this topic to SOLVED. It helps everybody! ....

    Also
    اس کی مدد کرتا ہے اگر
    شکریہ کہنے کے لئے سٹار کلک کریں
    If you are satisfied by any members response to your problem please consider using the small Star icon bottom left of their post to show your appreciation.

  27. #27
    Registered User
    Join Date
    07-07-2011
    Location
    Mumbai
    MS-Off Ver
    Excel 2003
    Posts
    36

    Re: Looping Problem

    no no.... plz dont take me wrong, ur code has to b precise
    i appreciate what u did for me

    it was my fault
    i hadnt mentioned precisely what i wanted to do with the code

+ 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