Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Worksheet Function


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


--
VBA Noob
------------------------------------------------------------------------
VBA Noob's Profile: http://www.excelforum.com/member.php...o&userid=33833
View this thread: http://www.excelforum.com/showthread...hreadid=554893

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Worksheet Function

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)

"VBA Noob" wrote in
message ...

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


--
VBA Noob
------------------------------------------------------------------------
VBA Noob's Profile:

http://www.excelforum.com/member.php...o&userid=33833
View this thread: http://www.excelforum.com/showthread...hreadid=554893



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Worksheet Function


Thanks Bob

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


VBA Noob


--
VBA Noob
------------------------------------------------------------------------
VBA Noob's Profile: http://www.excelforum.com/member.php...o&userid=33833
View this thread: http://www.excelforum.com/showthread...hreadid=554893

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Worksheet Function

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)

"VBA Noob" wrote in
message ...

Thanks Bob

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


VBA Noob


--
VBA Noob
------------------------------------------------------------------------
VBA Noob's Profile:

http://www.excelforum.com/member.php...o&userid=33833
View this thread: http://www.excelforum.com/showthread...hreadid=554893



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
Worksheet Function grobertson Excel Worksheet Functions 1 June 8th 07 05:55 PM
example using DSUM worksheet function in a VBA function excelman Excel Programming 3 February 9th 06 05:28 PM
Reference the worksheet from a multiple worksheet range function ( DBickel Excel Worksheet Functions 1 May 28th 05 03:49 AM
Can the offset worksheet function reference another worksheet AlistairJ Excel Worksheet Functions 2 May 9th 05 06:18 PM
formula/function to copy from worksheet to worksheet Jen Excel Programming 5 January 11th 05 08:22 PM


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

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

About Us

"It's about Microsoft Excel"