Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 184
Default Distribute Cost by Month

From a column of dates in A, and Cost in B
First : I generate the Month columns headers in the YYMM format,
starting in Column C, row 2.
Slight glitch there, I have to test if the current row
YearMonth of my "A" Dates Column is greater
than the YearMonth of the Last or Max Date
Second : I would like to distribute my Cost Column to the pertaining
months columns, either thru
a populated array or loop. This is where my main problem
is.
'
'Sub MonthCostDistrib()
Dim LastRow As Long
Dim rDate As Range
Dim dtMax As Date, dtMin As Date
Dim startdate As Date, enddate As Date
LastRow = Cells(65536, 1).End(xlUp).Row
x = 3
Set rDate = Range("A3:A" & LastRow)
'
'Find Start & End Dates
dtMax = Application.Max(rDate)
dtMin = Application.Min(rDate)
Range("C1").Activate
ActiveCell.Value = dtMin
Range("D1").Activate
ActiveCell.Value = dtMax
startdate = Range("C1").Value
enddate = Range("D1").Value
'
'Fill Calendar Month Headers
Do
With Cells(2, x)
.Value = startdate
.NumberFormat = "mmyy"
End With
startdate = DateAdd("m", 1, startdate)
x = x + 1
'
' Test if YearMonth(startdate) YearMonth(enddate)
Loop Until startdate enddate: ' Test has to be on YearMonth(Dates)
not on Date only
'
'Pseudo-Code
'Loop thru A:B Columns and distribute Cost in Months Columns
' Dim rDateArray(rDate,1) : 'Dim Array of Dates and Cost
' Populate array with YearMonth(rDate) and Cost
' Distribute array in Months Columns
'
End Sub
'
Help appreciated
J.P.
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
Creating a total cost chart where a component cost is a step cost gvm Charts and Charting in Excel 0 April 28th 10 02:10 PM
How to distribute/spread/map cost of project across different year Dream Excel Discussion (Misc queries) 3 September 3rd 09 12:09 PM
How do I distribute cost among group of employees based on salary Denise Excel Discussion (Misc queries) 3 May 6th 09 02:43 PM
Month calculation from cost for a business plan - please help Juergen L Excel Discussion (Misc queries) 3 December 23rd 08 09:18 PM
Cost History by Customer & by Month. Extending existing code. u473 Excel Programming 0 December 22nd 08 09:02 PM


All times are GMT +1. The time now is 02:43 AM.

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"