+ Reply to Thread
Results 1 to 2 of 2

Help Needed on Calculating Sum - VBA Code

  1. #1
    Registered User
    Join Date
    08-10-2020
    Location
    Chennai
    MS-Off Ver
    2006
    Posts
    4

    Help Needed on Calculating Sum - VBA Code

    Hello All,

    I am trying to calculate the sum for range of row and column values, which I am passing dynamically through for-loop. My code is as follow as :

    Dim Total as Long

    Total = WorksheetFunction.Sum(Range(ThisWorkbook.Sheets("Sheet1").Cells(startrow, x): ThisWorkbook.Sheets("Sheet1").Cells(endrow, x))))

    The above code didn't throw any error, however Total returned zero values,while the sheet1 have valid values and the sum shouldn't be zero. The Range of start and end row I am passing dynamically and x - represents column I am incrementing through For-loop. (Also verified through MsgBox that start/endrow fetching the correct rows).So could you please help me to fix this issue.

    Thanks in Advance!

  2. #2
    Forum Expert torachan's Avatar
    Join Date
    12-27-2012
    Location
    market harborough, england
    MS-Off Ver
    Excel 2010
    Posts
    4,308

    Re: Help Needed on Calculating Sum - VBA Code

    Please Login or Register  to view this content.
    x is your startcolumn, y is endcolumn
    put these parameters in cells A1:D1 resulting addition occurs in E1
    Last edited by torachan; 08-16-2020 at 10:43 AM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Calculating value needed to reach a certain % goal
    By Mrjpjones in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 06-14-2016, 03:38 PM
  2. Calculating dropout help needed!!!
    By cicapuki in forum Excel General
    Replies: 1
    Last Post: 12-28-2015, 03:59 PM
  3. Formula needed for calculating Sqft
    By scottjones335 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 01-18-2015, 04:52 PM
  4. Help needed: Calculating SLA only for working hours
    By Elangovan89 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 09-03-2014, 09:45 AM
  5. Calculating what is needed to meet a certain percentage
    By cg380 in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 04-15-2013, 06:46 PM
  6. Calculating Probability help needed
    By misterboy in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-24-2011, 05:17 AM
  7. Calculating needed responses
    By brian01tj in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 11-14-2008, 06:03 PM

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