+ Reply to Thread
Results 1 to 5 of 5

Subtotal according to changing number of columns

  1. #1
    Registered User
    Join Date
    02-19-2004
    Posts
    57

    Subtotal according to changing number of columns

    Hi I need help with the subtotal code:

    Please see attached image to understand how my table will look like for a full year.

    I need to produce YTD tables where not all months will be included.
    For Jan YTD, my code will look like this:
    Please Login or Register  to view this content.
    For Jun YTD, my code will look like this:
    Please Login or Register  to view this content.
    and for Dec YTD, my code will look like this:
    Please Login or Register  to view this content.
    How can i automate this instead of changing the array every month?
    Any help is greatly appreciated!
    Attached Images Attached Images
    Last edited by josnah; 01-13-2008 at 01:20 AM.

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello josnah,

    The easiest way to automate this would be to first create 3 separate macros in a Standard VBA module and then add 3 command buttons to your worksheet. Assign one macro to one button. Then you can click the button you want to display the required YTD totals.

    Sincerely,
    Leith Ross

  3. #3
    Registered User
    Join Date
    02-19-2004
    Posts
    57
    hi Leith,

    thanks for the suggestion. but then i'll need to create 12 seperate macros & commandbuttons for each month of the year.

    but i was looking at sth more like...
    if the 3rd last column is a particular month, then the array should change accordingly as listed below.

    Month ArrayList
    Jan 3,4
    Feb 3,4,5
    Mar 3,4,5,6
    Apr 3,4,5,6,7
    May 3,4,5,6,7,8
    Jun 3,4,5,6,7,8,9
    Jul 3,4,5,6,7,8,9,10
    Aug 3,4,5,6,7,8,9,10,11
    Sep 3,4,5,6,7,8,9,10,11,12
    Oct 3,4,5,6,7,8,9,10,11,12,13
    Nov 3,4,5,6,7,8,9,10,11,12,13,14
    Dec 3,4,5,6,7,8,9,10,11,12,13,14,15

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello josnah,

    This macro can be attached to a single button. It will prompt you for the month and then perform the YTD calculation.
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

  5. #5
    Registered User
    Join Date
    02-19-2004
    Posts
    57
    Hi Leith,

    Many thanks for your post. That works for me...
    I'm beginning to understand how to use Select Case now!

    Josnah
    Last edited by josnah; 01-13-2008 at 01:50 PM.

+ 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