+ Reply to Thread
Results 1 to 10 of 10

coding to add values until a certain limit

Hybrid View

  1. #1
    Forum Expert
    Join Date
    07-16-2010
    Location
    Northumberland, UK
    MS-Off Ver
    Excel 2007 (home), Excel 2010 (work)
    Posts
    3,054

    Re: coding to add values until a certain limit

    OK, you've got numerous problems with your code.

    In no particular order:

    1. The syntax of your For Next loop is wrong, it's For i=0 to 1000000, not for i=0 to i=100000 - that is a boolean statement which evalutes to 0, so your loop says For i=0 to 0, which is why it only copies the first row.

    2. You don't need to manually increment i - that's what the loop does.

    3. A for next loop is the wrong tool for the job anyway, you'd be better off manually incrementing i and having the whole lot in a While sum=<budget ... wend loop.

  2. #2
    Forum Contributor
    Join Date
    08-04-2010
    Location
    singapore
    MS-Off Ver
    Excel 2007
    Posts
    143

    Re: coding to add values until a certain limit

    i see. while,wend works well. thanks for ur help btw do u know what code can i use to show the values of "risk value" and "cost" from sheet 1 instead of copying the entire row? i am supposed to show only the location,risk value and cost in sheet 2. if i remove the values of other factors, "risk value" and "cost" will turn to 0.

+ 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