+ Reply to Thread
Results 1 to 6 of 6

Looping problem, formula is summing all workbooks as it goes...

  1. #1
    Registered User
    Join Date
    08-11-2009
    Location
    Gilbert, Arizona, USA
    MS-Off Ver
    Excel 2003
    Posts
    82

    Looping problem, formula is summing all workbooks as it goes...

    I have a bit of code that works well when I convert one file at a time. However, when I loop the macro to convert all folders in a file, it seems to tally up the sum from the previous file and add it to the current file as it converts. The more files it converts, the higher this particular number gets. It is still summing the correct # but it is adding previous workbook sums to it. Does this make sense?

    Also, is there a better way to write this code instead of jumping to the very last possible row in excel before counting up? i.e. "C65536"

    here is the code I am using:
    Please Login or Register  to view this content.
    thanks!
    Last edited by curbster; 08-20-2009 at 01:36 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, formula is summing all workbooks as it goes...

    Hello curbster,

    It would be a big help if you post your workbook.
    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
    Forum Expert davegugg's Avatar
    Join Date
    12-18-2008
    Location
    WI, US
    MS-Off Ver
    2010
    Posts
    1,884

    Re: Looping problem, formula is summing all workbooks as it goes...

    I would say right after your begin loop code, put:
    Please Login or Register  to view this content.
    I was recently told the best way to do the last cell is:

    Please Login or Register  to view this content.
    Hope that helps!
    Is your code running too slowly?
    Does your workbook or database have a bunch of duplicate pieces of data?
    Have a look at this article to learn the best ways to set up your projects.
    It will save both time and effort in the long run!


    Dave

  4. #4
    Registered User
    Join Date
    08-11-2009
    Location
    Gilbert, Arizona, USA
    MS-Off Ver
    Excel 2003
    Posts
    82

    Re: Looping problem, formula is summing all workbooks as it goes...

    Dave thanks for the code. I was able to get it to reset by placing the cellcount=0 in the line just below where I dimensioned "cellcount" and it worked! so thank you!

    Also, the bit of code you gave to count to last cell worked in one area but not the others. Its probably how I've jimmy-rigged my code to work. I am really just a beginner. Anyone know how to shorten these lines to reflect the
    Please Login or Register  to view this content.
    that you gave me?

    here is what I've come up with. it works but its sloppy and runs a bit slow throughout the loop.

    Please Login or Register  to view this content.
    Leith, I am working with a lot of sensitive information and since I'm starting with tab delimited text files I'm not sure how to post an example.

  5. #5
    Forum Contributor
    Join Date
    02-27-2008
    Posts
    764

    Re: Looping problem, formula is summing all workbooks as it goes...

    Hi
    try these codes
    Please Login or Register  to view this content.
    Ravi

  6. #6
    Registered User
    Join Date
    08-11-2009
    Location
    Gilbert, Arizona, USA
    MS-Off Ver
    Excel 2003
    Posts
    82

    Re: Looping problem, formula is summing all workbooks as it goes...

    Hi Ravi,
    Thank you for the code. I put it in and it sent me to someplace else in the code with a debug error so I think it is not looping properly. When I use the code I started with, it does work. I'm not sure whats causing it though.

+ 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