Consulting

Results 1 to 6 of 6

Thread: Sum with integer

  1. #1
    VBAX Regular
    Joined
    Oct 2020
    Posts
    24
    Location

    Sum with integer

    Hello,

    How can I sum with vba, wih integer, code is
    Worksheets("Turnus").Cells(l,39).Value= Application.WorksheetFunction.Sum(Range(Cells(l,60),Cells(l+87)))

    this code not working, sum number is wrong

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,455
    Location
    Bit light on detail, but maybe this is what you want

    With Worksheets("Turnus")
    	.Cells(l,39).Value= Application.Sum(.Range(.Cells(l,60),.Cells(l,87)))
    End With
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,743
    Location
    I'm guessing that you meant Row 1 (not "l") and that you wanted to sum the cells between columns 60 and 87 in row 1 (not l+87)


    Worksheets("Turnus").Cells(1,39).Value= Application.WorksheetFunction.Sum(Range(Cells(1,60),Cells(1,87)))
    
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

  4. #4
    [Turnus!AM1]=[sum(Turnus!BR1:CS1)]

  5. #5
    VBAX Regular
    Joined
    Oct 2020
    Posts
    24
    Location
    L is integer, beacuse I have 150 row to sum.
    Sum 1 line, and then go to the next line (but sum is the same colums). I wrote a mistake, yes colums 60 to 87

  6. #6
    msgbox [sum(Turnus!BR1:CS150)]

Posting Permissions

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