var sidebar_align = 'right';
var content_container_margin = parseInt('290px');
var sidebar_width = parseInt('270px');
Unanswered: using a function result in a cell formula
I would like to have cell c1 = cell b1 - 3 months, (b1 is a date 6/30/04) how can i create a function in vba and ref that function in the cell formula. some thing like :
pub func priorQtr as date
dim m as int = cint(range(b1).value).month -3
dim d as int = cdate(m & "/01/" & now.year).daysinmonth
return cdate(m & "/" & d & "/" & now.year)
As u can c im not used to vba so any help with getting my date would also b aprreciated
Place this in cell C1
=DATE(YEAR(B1), MONTH(B1) - 3, DAY(B1))
1 - if q2 ends 6/30/04 the result is 3/30/04 not 3/31 which it should be.
2 - my cell b8 formula is : =RIGHT(A3,8) and that doenst work with the Date function
Either nest a bunch of IF statements or...
If the problem is getting the last day of the month for each end of the quarter, I'd guess that you would need to nest a bunch of If Statements.
In VBA a more workable solution would be to use SELECT CASE.
yes about the case, but i would like to put a formula in the cell that would return the results of my function.
Any one ever do that?
I dont want to have to keep running a macro, im a lazy FSB
Play with this to see if it's what you want. Beware of strange things such as 5/30/2004 (not an end of a month) calculating to 2/29/2004 (an end of a month).
'Need more information on the problem with cell B8.
Last edited by actuary; 05-16-04 at