Worksheet Function

V

VBA Noob

Hi all,

How would I add this formula as a worksheet function with VBA

I can't see INT, MOD or Year in VBA. Also want to change C2 to change
to activecell column + row 2.

=INT(((C2-1461)-SUM(MOD(DATE(YEAR(C2-MOD(C2,7)+3),1,2)-1461,{1E+99,7})*{1,-1})+5)/7)

Thanks in advance for your help

VBA Noob
 
B

Bob Phillips

MsgBox
Activesheet.Evaluate("INT(((C2-1461)-SUM(MOD(DATE(YEAR(C2-MOD(C2,7)+3),1,2)-
1461,{1E+99,7})*{1,-1})+5)/7)")

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)
 
V

VBA Noob

Thanks Bob

I will try to amend your formula to change C2 to active Column and Row
2


VBA Noob
 
B

Bob Phillips

That's is not so easy mate. You might be best to pick up activecell like so

sFormula = "INT(((" & ActiveCell.Address(False, False) & _
"-1461)-SUM(MOD(DATE(YEAR(" & ActiveCell.Address(False, False) &
_
"-MOD(" & ActiveCell.Address(False, False) & _
",7)+3),1,2)-1461,{1E+99,7})*{1,-1})+5)/7)"
myVal = ActiveSheet.Evaluate(sFormula)

B TW, what is it a formula for? I get 25 if the date is TODAY().


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top