Consulting

Results 1 to 8 of 8

Thread: how do i sum a total of multiple numbers

  1. #1
    Banned VBAX Regular
    Joined
    Sep 2009
    Posts
    20
    Location

    how do i sum a total of multiple numbers

    the numbers are not in a single row or column so how do i do that?!! please help. in vba that is

  2. #2
    VBAX Tutor nst1107's Avatar
    Joined
    Nov 2008
    Location
    Monticello
    Posts
    245
    Location
    Not sure of your particular situation, but supposing you have values in A1:A5 and B12:G12 and Z22 that you'd like to sum. And supposing you have a variable, sumOfRanges, that you'd like to assign the sum to. The code could look something like this:[vba]sumOfRanges = WorksheetFunction.Sum("A1:A5", "B12:G12", "Z22")[/vba]

  3. #3
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    You need to give more detail or post an example.
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  4. #4
    VBAX Wizard
    Joined
    May 2004
    Posts
    6,713
    Location
    Don't bother.

  5. #5
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,060
    Location
    Hmmm... you know something we should be aware of fumei?
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  6. #6
    Knowledge Base Approver VBAX Guru GTO's Avatar
    Joined
    Sep 2008
    Posts
    3,368
    Location
    Hi Ted

    A howdy and hope all is great with you and yours!

    I'm not sure whether "Don't look a gift horse in the mouth." is a saying down there, but by golly, the offer of extended and extra effort was muzzle-punched here.

    http://vbaexpress.com/forum/showthread.php?t=28373

    A great day to your and yours,

    Mark

  7. #7
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,060
    Location
    Mark, maybe the OP was having an off day with the other question. How about we give another chance to communicate? Maybe this time it'll be better for all of us.
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  8. #8
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    Ted, they should still know about the other thread. I was getting ready to post a link to it but noticed that Mark had already done as much.
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •