Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default macro to do subtotal by eachqtr in calendar year

Hi MVPs,

I have written a macro to calculate the budget each month which inserts row,
the lines in the excel based on the date range given by month wise. I need
now to calculate the quarterly subtotal for the months given in teh date
range.

for eg;) date range 01-jan-09 to 31-mar-09
Jan-09 1000
Feb-09 1000
Mar-09 1000
Qtr 1 09 3000

Thanks for your replies.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,646
Default macro to do subtotal by eachqtr in calendar year

One way:

Create a helper column for quarters with this formula (A2 being the date):
=LOOKUP(MONTH(A2),{1,2,3,4,5,6,7,8,9,10,11,12},{1, 1,1,2,2,2,3,3,3,4,4,4})
Create subtotals by this helper column as usual!

Regards,
Stefi

€˛yagna€¯ ezt Ć*rta:

Hi MVPs,

I have written a macro to calculate the budget each month which inserts row,
the lines in the excel based on the date range given by month wise. I need
now to calculate the quarterly subtotal for the months given in teh date
range.

for eg;) date range 01-jan-09 to 31-mar-09
Jan-09 1000
Feb-09 1000
Mar-09 1000
Qtr 1 09 3000

Thanks for your replies.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default macro to do subtotal by eachqtr in calendar year

Hi Stefi,

thanks, I am looking for VBA code in excel 2003.

"Stefi" wrote:

One way:

Create a helper column for quarters with this formula (A2 being the date):
=LOOKUP(MONTH(A2),{1,2,3,4,5,6,7,8,9,10,11,12},{1, 1,1,2,2,2,3,3,3,4,4,4})
Create subtotals by this helper column as usual!

Regards,
Stefi

€˛yagna€¯ ezt Ć*rta:

Hi MVPs,

I have written a macro to calculate the budget each month which inserts row,
the lines in the excel based on the date range given by month wise. I need
now to calculate the quarterly subtotal for the months given in teh date
range.

for eg;) date range 01-jan-09 to 31-mar-09
Jan-09 1000
Feb-09 1000
Mar-09 1000
Qtr 1 09 3000

Thanks for your replies.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,646
Default macro to do subtotal by eachqtr in calendar year

Something like this?

Sub quartersubtot()
lastdate = Range("A" & Rows.Count).End(xlUp).Row
Range("D2").FormulaR1C1 = _

"=LOOKUP(MONTH(RC[-3]),{1,2,3,4,5,6,7,8,9,10,11,12},{1,1,1,2,2,2,3,3,3, 4,4,4})"
Selection.AutoFill Destination:=Range("D2:D" & lastdate),
Type:=xlFillDefault
Range("A1").Select
Selection.Subtotal GroupBy:=4, Function:=xlSum, TotalList:=Array(3), _
Replace:=True, PageBreaks:=False, SummaryBelowData:=True
End Sub

Column A for dates,
column D for quarters.

Stefi


€˛yagna€¯ ezt Ć*rta:

Hi Stefi,

thanks, I am looking for VBA code in excel 2003.

"Stefi" wrote:

One way:

Create a helper column for quarters with this formula (A2 being the date):
=LOOKUP(MONTH(A2),{1,2,3,4,5,6,7,8,9,10,11,12},{1, 1,1,2,2,2,3,3,3,4,4,4})
Create subtotals by this helper column as usual!

Regards,
Stefi

€˛yagna€¯ ezt Ć*rta:

Hi MVPs,

I have written a macro to calculate the budget each month which inserts row,
the lines in the excel based on the date range given by month wise. I need
now to calculate the quarterly subtotal for the months given in teh date
range.

for eg;) date range 01-jan-09 to 31-mar-09
Jan-09 1000
Feb-09 1000
Mar-09 1000
Qtr 1 09 3000

Thanks for your replies.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
calendar year versus fiscal year mePenny Excel Discussion (Misc queries) 4 November 17th 09 06:05 PM
Help dealing with a fiscal year rather than a calendar year Tyler Excel Worksheet Functions 3 August 25th 07 11:26 AM
change the year in a calendar template to different year George Excel Discussion (Misc queries) 1 July 19th 06 07:34 PM
Subtotal by Year, Large Spreadsheet? Tom Ogilvy Excel Programming 0 May 14th 05 09:52 PM
Subtotal by Year, Large Spreadsheet? Ron de Bruin Excel Programming 0 May 14th 05 09:37 PM


All times are GMT +1. The time now is 10:18 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"