+ Reply to Thread
Results 1 to 5 of 5

How to return sum of a range with fixed starting cell and variable length

  1. #1
    Registered User
    Join Date
    04-11-2011
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    4

    How to return sum of a range with fixed starting cell and variable length

    Hi,

    I am trying to write a macro where I have offset from a cell and then make a range by going down rows and have to repeat that multipe times.

    SO my starting point is fixed. in Excel term its will be like '=sum(offset("start",0,p,q)

    Start is name of fixed cell and p and q are variables.
    How can I do this in VBA?

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,469

    Re: How to return sum of a range with fixed starting cell and variable length

    An example:

    Please Login or Register  to view this content.

    Based on data in column A with a heading in row 1.

    Regards
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Forum Expert Bob Phillips's Avatar
    Join Date
    09-03-2005
    Location
    Wessex
    MS-Off Ver
    Office 2003, 2010, 2013, 2016, 365
    Posts
    3,284

    Re: How to return sum of a range with fixed starting cell and variable length

    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    04-11-2011
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: How to return sum of a range with fixed starting cell and variable length

    HI Bob

    I am offsettting by p columns and then stratching bt q rows

    SO would my code be application.sum(range("start").offset(0,p).resize(q,0)) ?

  5. #5
    Registered User
    Join Date
    04-11-2011
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: How to return sum of a range with fixed starting cell and variable length

    |Sorry that wld be (q,1)

    Thanks a lot!!!

+ 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