+ Reply to Thread
Results 1 to 2 of 2

Adding in loop

  1. #1
    Sally Mae
    Guest

    Adding in loop

    I have a macro that now adds in a strange fashion. It used to work but now
    for some reason the adding in one loop is wrong. When there are decimal
    numbers in the cells that the loop is to add the program just puts them
    together so that there are several decimal commas. The code is:

    For l = 1 To i - 1
    dblSumMarketValue = dblSumMarketValue + rng5.Offset(l, 0).Value
    Next

    For l = 1 To i - 1
    dblSumMarketValueBench = dblSumMarketValueBench + rng6.Offset(l,
    0).Value
    Next

    The last loop is the one having the problem. It used to work but now it just
    puts the number together. The contents of the cells are pasted in from
    another program and are then checked by a function that remove blanks (don’t
    know if that has any impact..). Please help me if you can!


  2. #2
    Don Guillett
    Guest

    Re: Adding in loop

    why not just use
    dsmv=Application.Sum(Range("a2:a4"))
    or
    Application.Sum(Range(Cells(2, "a"), Cells(4, "a")))
    --
    Don Guillett
    SalesAid Software
    [email protected]
    "Sally Mae" <[email protected]> wrote in message
    news:[email protected]...
    >I have a macro that now adds in a strange fashion. It used to work but now
    > for some reason the adding in one loop is wrong. When there are decimal
    > numbers in the cells that the loop is to add the program just puts them
    > together so that there are several decimal commas. The code is:
    >
    > For l = 1 To i - 1
    > dblSumMarketValue = dblSumMarketValue + rng5.Offset(l, 0).Value
    > Next
    >
    > For l = 1 To i - 1
    > dblSumMarketValueBench = dblSumMarketValueBench + rng6.Offset(l,
    > 0).Value
    > Next
    >
    > The last loop is the one having the problem. It used to work but now it
    > just
    > puts the number together. The contents of the cells are pasted in from
    > another program and are then checked by a function that remove blanks (don't
    > know if that has any impact..). Please help me if you can!
    >




+ 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