+ Reply to Thread
Results 1 to 8 of 8

vba code to sum the values of a column by year

  1. #1
    Registered User
    Join Date
    08-10-2016
    Location
    Ireland
    MS-Off Ver
    2013
    Posts
    67

    vba code to sum the values of a column by year

    Hi experts,

    Please refer the sample data attached. I need to sum the values of column B if the year in column A is 2021 in "Sheet1" and need the result in "Sheet2". There are no fixed number of rows in the columns.
    I need the vba script but I am struggling to write it. Can somebody help me please?

    Apologies if this has been solved earlier and thanks in advance...

    Abhi
    Attached Files Attached Files

  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
    48,089

    Re: vba code to sum the values of a column by year

    One way:

    Please Login or Register  to view this content.
    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
    Registered User
    Join Date
    08-10-2016
    Location
    Ireland
    MS-Off Ver
    2013
    Posts
    67

    Re: vba code to sum the values of a column by year

    Quote Originally Posted by TMS View Post
    One way:

    Please Login or Register  to view this content.
    Thanks, this worked for me

  4. #4
    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
    48,089

    Re: vba code to sum the values of a column by year

    You're welcome. Thanks for the rep.

  5. #5
    Registered User
    Join Date
    08-10-2016
    Location
    Ireland
    MS-Off Ver
    2013
    Posts
    67

    Re: vba code to sum the values of a column by year

    Hi TMS,

    Sorry for coming back to you on the same query again.

    Just wondering what would be the formula if I need to sum the values between the dates, say from 31/07/2021 to 31/12/2021 for the variable range of data?

    Many Thanks,
    Abhi

  6. #6
    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
    48,089

    Re: vba code to sum the values of a column by year

    Not sure why youwant this in VBA; you could just use the formulae directly.

    Whatever

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    08-10-2016
    Location
    Ireland
    MS-Off Ver
    2013
    Posts
    67

    Re: vba code to sum the values of a column by year

    Thank you TMS, this helps

  8. #8
    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
    48,089

    Re: vba code to sum the values of a column by year

    You're welcome.

+ 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. Getting current year/month/day values and inserting them into macro code
    By joe_schmo95 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-26-2021, 04:05 AM
  2. [SOLVED] macro code for comparing month-year then add next column value
    By k1dr0ck in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-04-2018, 04:47 AM
  3. VBA code to search through column and allocate to year
    By pokopikos13 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-23-2017, 10:08 AM
  4. Year values in the column
    By Lana74 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 10-18-2016, 04:58 PM
  5. Sum values for month and year where cells in column contain word
    By serverlift in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 11-25-2015, 05:08 PM
  6. [SOLVED] Count values in column, paste current year in another column that many times
    By johnstevens in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 06-05-2014, 02:32 PM
  7. Sorting Column Values (Ascending Year)
    By jimmy_nora in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-12-2010, 04:18 AM

Tags for this Thread

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