Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 29
Default Array formula in VBA

Hi,

I want to replace the following VBA code;

' guess 15-day date!
InBy_Box.Text = DateValue(Referral_Box.Text) + 21

Where 21 days are guessed from the referral date, with the following
equivlant formula;


=A2+IF(B$2=0,0,SIGN(B$2)*SMALL(IF((WEEKDAY(A2+SIGN (B$2)*(ROW(INDIRECT("1:"&ABS(B$2)*10))),2)<6)*ISNA (MATCH(A2+SIGN(B$2)*(ROW(INDIRECT("1:"&ABS(B$2)*10 ))),C$2:C$3,0)),ROW(INDIRECT("1:"&ABS(B$2)*10))),A BS(B$2)))

This Array formula is work around for the Workday function if no analysis
tool pak can be included, however i need to know how this should be
transcribed into VBA, so that upon entering the referral date in a form the
future date (workdays) automatically calculates. Please help i'm really stuck
and do not know much about this line of VBA.

Thanks In Advance


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Array formula in VBA

Do something like this pseudo code.

Dim cnt as Long, dt as Date
dt = DataValue("01/01/2006")
do while cnt < 15
dt = dt + 1
if weekday(dt,2) < 6 then cnt = cnt + 1
Loop

--
Regards,
Tom Ogilvy



"sdg8481" wrote in message
...
Hi,

I want to replace the following VBA code;

' guess 15-day date!
InBy_Box.Text = DateValue(Referral_Box.Text) + 21

Where 21 days are guessed from the referral date, with the following
equivlant formula;


=A2+IF(B$2=0,0,SIGN(B$2)*SMALL(IF((WEEKDAY(A2+SIGN (B$2)*(ROW(INDIRECT("1:"&ABS(B$2)*10))),2)<6)*ISNA (MATCH(A2+SIGN(B$2)*(ROW(INDIRECT("1:"&ABS(B$2)*10 ))),C$2:C$3,0)),ROW(INDIRECT("1:"&ABS(B$2)*10))),A BS(B$2)))

This Array formula is work around for the Workday function if no analysis
tool pak can be included, however i need to know how this should be
transcribed into VBA, so that upon entering the referral date in a form
the
future date (workdays) automatically calculates. Please help i'm really
stuck
and do not know much about this line of VBA.

Thanks In Advance




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 29
Default Array formula in VBA

Hi,

Thanks for this but i can't seem to get it working, and i don't think it
takes into account holidays etc..... Also i also need it to calculate 13 and
8 working days in advance which obviously isn't so easy as 15. what does the
dt represent. Is it not possible to to use the earlier formula in VBA. Thanks

"Tom Ogilvy" wrote:

Do something like this pseudo code.

Dim cnt as Long, dt as Date
dt = DataValue("01/01/2006")
do while cnt < 15
dt = dt + 1
if weekday(dt,2) < 6 then cnt = cnt + 1
Loop

--
Regards,
Tom Ogilvy



"sdg8481" wrote in message
...
Hi,

I want to replace the following VBA code;

' guess 15-day date!
InBy_Box.Text = DateValue(Referral_Box.Text) + 21

Where 21 days are guessed from the referral date, with the following
equivlant formula;


=A2+IF(B$2=0,0,SIGN(B$2)*SMALL(IF((WEEKDAY(A2+SIGN (B$2)*(ROW(INDIRECT("1:"&ABS(B$2)*10))),2)<6)*ISNA (MATCH(A2+SIGN(B$2)*(ROW(INDIRECT("1:"&ABS(B$2)*10 ))),C$2:C$3,0)),ROW(INDIRECT("1:"&ABS(B$2)*10))),A BS(B$2)))

This Array formula is work around for the Workday function if no analysis
tool pak can be included, however i need to know how this should be
transcribed into VBA, so that upon entering the referral date in a form
the
future date (workdays) automatically calculates. Please help i'm really
stuck
and do not know much about this line of VBA.

Thanks In Advance





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Array formula in VBA

s =
"A2+IF(B$2=0,0,SIGN(B$2)*SMALL(IF((WEEKDAY(A2+SIGN (B$2)*(ROW(INDIRECT(""1:""&ABS(B$2)*10))),2)<6)*IS NA(MATCH(A2+SIGN(B$2)*(ROW(INDIRECT(""1:""&ABS(B$2 )*10))),C$2:C$3,0)),ROW(INDIRECT(""1:""&ABS(B$2)*1 0))),ABS(B$2)))"

result = Evaluate(s)



--
Regards,
Tom Ogilvy



"sdg8481" wrote in message
...
Hi,

Thanks for this but i can't seem to get it working, and i don't think it
takes into account holidays etc..... Also i also need it to calculate 13
and
8 working days in advance which obviously isn't so easy as 15. what does
the
dt represent. Is it not possible to to use the earlier formula in VBA.
Thanks

"Tom Ogilvy" wrote:

Do something like this pseudo code.

Dim cnt as Long, dt as Date
dt = DataValue("01/01/2006")
do while cnt < 15
dt = dt + 1
if weekday(dt,2) < 6 then cnt = cnt + 1
Loop

--
Regards,
Tom Ogilvy



"sdg8481" wrote in message
...
Hi,

I want to replace the following VBA code;

' guess 15-day date!
InBy_Box.Text = DateValue(Referral_Box.Text) + 21

Where 21 days are guessed from the referral date, with the following
equivlant formula;


=A2+IF(B$2=0,0,SIGN(B$2)*SMALL(IF((WEEKDAY(A2+SIGN (B$2)*(ROW(INDIRECT("1:"&ABS(B$2)*10))),2)<6)*ISNA (MATCH(A2+SIGN(B$2)*(ROW(INDIRECT("1:"&ABS(B$2)*10 ))),C$2:C$3,0)),ROW(INDIRECT("1:"&ABS(B$2)*10))),A BS(B$2)))

This Array formula is work around for the Workday function if no
analysis
tool pak can be included, however i need to know how this should be
transcribed into VBA, so that upon entering the referral date in a form
the
future date (workdays) automatically calculates. Please help i'm really
stuck
and do not know much about this line of VBA.

Thanks In Advance







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
Array formula SUMIF with 2D sum_range array Rich_84 Excel Worksheet Functions 3 April 3rd 09 10:46 PM
Array formula: how to join 2 ranges together to form one array? Rich_84 Excel Worksheet Functions 2 April 1st 09 06:38 PM
Find specific value in array of array formula DzednConfsd Excel Worksheet Functions 2 January 13th 09 06:19 AM
Tricky array formula issue - Using array formula on one cell, then autofilling down a range aspenbordr Excel Programming 0 July 27th 05 03:59 PM
Convert Normal formula to array formula Pradip Jain Excel Programming 4 May 23rd 05 04:32 PM


All times are GMT +1. The time now is 04:57 PM.

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"