#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 19
Default Formula to VBA codes

is there any way to do this using VBA?

=-(IF(AND(WEEKDAY(A1,2)<6,MOD(A1,1)17/24),1,0)+WEEKDAY(A1,2)6)+2*(IF
(AND( WEEKDAY(A1,2)<6,MOD(A1,1)17/24),1,0)+WEEKDAY(A1,2)5)+A1

thanks
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 449
Default Formula to VBA codes

Sure. What does it do and why ?

Best wishes Harald

"Savio" wrote in message
...
is there any way to do this using VBA?

=-(IF(AND(WEEKDAY(A1,2)<6,MOD(A1,1)17/24),1,0)+WEEKDAY(A1,2)6)+2*(IF
(AND( WEEKDAY(A1,2)<6,MOD(A1,1)17/24),1,0)+WEEKDAY(A1,2)5)+A1

thanks


  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5,441
Default Formula to VBA codes

Savio,

Sure. Just process the formula with Format and Evaluate:

MsgBox Format(Evaluate("-(IF(AND(WEEKDAY(A1,2)<6,MOD(A1,1)17/24),1,0)" & _
"+WEEKDAY(A1,2)6)+2*(IF(AND(WEEKDAY(A1,2)<6,MOD(A 1,1)17/24),1,0)" & _
"+WEEKDAY(A1,2)5)+A1"), "mmmm dd, yyyy")

HTH,
Bernie
MS Excel MVP


"Savio" wrote in message
...
is there any way to do this using VBA?

=-(IF(AND(WEEKDAY(A1,2)<6,MOD(A1,1)17/24),1,0)+WEEKDAY(A1,2)6)+2*(IF
(AND( WEEKDAY(A1,2)<6,MOD(A1,1)17/24),1,0)+WEEKDAY(A1,2)5)+A1

thanks



  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 690
Default Formula to VBA codes

Hi. Just a note. I may be wrong here though.

+WEEKDAY(A1,2)5)

This took advantage of Excel returning an implied 1 or 0.
Perhaps do this with the others.

-(IF(AND(WEEKDAY(A1,2)<6,MOD(A1,1)17/24),1,0)

So, subtract 1 if it's a weekday and after hours (5pm)

AND(WEEKDAY(A1,2)<6,MOD(A1,1)17/24)

and then later add 2 if it's the same thing..

+2*(IF(AND( WEEKDAY(A1,2)<6,MOD(A1,1)17/24)

Could these be simplified?

Dana DeLouis


Savio wrote:
is there any way to do this using VBA?

=-(IF(AND(WEEKDAY(A1,2)<6,MOD(A1,1)17/24),1,0)+WEEKDAY(A1,2)6)+2*(IF
(AND( WEEKDAY(A1,2)<6,MOD(A1,1)17/24),1,0)+WEEKDAY(A1,2)5)+A1

thanks

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
formula for Canadian postal codes LB Excel Worksheet Functions 7 July 18th 07 12:07 AM
Convert Column Formula into VBA codes tqm1 Excel Discussion (Misc queries) 0 July 6th 07 01:28 PM
Tricky Formula Codes *** Urgent *** SweetSin80 Excel Discussion (Misc queries) 3 February 14th 06 01:36 AM
Tricky Formula Codes ***Urgent*** SweetSin80 Excel Discussion (Misc queries) 2 February 13th 06 09:27 PM
Formula to look up zip codes mikeburg Excel Discussion (Misc queries) 4 January 21st 06 07:25 PM


All times are GMT +1. The time now is 12:33 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"