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

i am writing a macro and would like to insert a formula in like this

Range("H10").FormulaArray =
"=IF((WEEKDAY(DATE(YEAR(H9)+$D$1,MONTH(H9)+$D$2,DA Y(H9)+$D$3),1)-1)*(WEEKDA*Y(DATE(YEAR(H9)+$D$1,MONTH(H9)+$D$2,DAY (H9)+$D$3),1)-7)=0,WORKDAY(DATE(YEAR*(H9)+$D$1,MONTH(H9)+$D$2,DA Y(H9)+$D$3),-1),DATE(YEAR(H9)+$D$1,MONTH(H9)+$D$*2,DAY(H9)+$D$3 ))"



the formula works fine.. but the '=' sign inside the quotes is causing
some problems


how do i overcome this.
basically i am trying to add one month to a date. if the result is not
a weekday, then, i shift the result to one previous weekday

thanks a lot in advance

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,440
Default insert formula

<the '=' sign inside the quotes is causing some problems

What problems? And what does "formula works fine" mean?

--
Kind regards,

Niek Otten


wrote in message oups.com...
i am writing a macro and would like to insert a formula in like this

Range("H10").FormulaArray =
"=IF((WEEKDAY(DATE(YEAR(H9)+$D$1,MONTH(H9)+$D$2,DA Y(H9)+$D$3),1)-1)*(WEEKDA*Y(DATE(YEAR(H9)+$D$1,MONTH(H9)+$D$2,DAY (H9)+$D$3),1)-7)=0,WORKDAY(DATE(YEAR*(H9)+$D$1,MONTH(H9)+$D$2,DA Y(H9)+$D$3),-1),DATE(YEAR(H9)+$D$1,MONTH(H9)+$D$*2,DAY(H9)+$D$3 ))"



the formula works fine.. but the '=' sign inside the quotes is causing
some problems


how do i overcome this.
basically i am trying to add one month to a date. if the result is not
a weekday, then, i shift the result to one previous weekday

thanks a lot in advance


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default insert formula

s1 =
"=IF((WEEKDAY(DATE(YEAR(H9)+$D$1,MONTH(H9)+$D$2,DA Y(H9)+$D$3),1)-1)*(WEEKDAY(DATE(YEAR(H9)+$D$1,MONTH(H9)+$D$2,DAY( H9)+$D$3),1)-7)=0,WORKDAY(DATE(YEAR(H9)+$D$1,MONTH(H9)+$D$2,DAY (H9)+$D$3),-1),DATE(YEAR(H9)+$D$1,MONTH(H9)+$D$2,DAY(H9)+$D$3) )"
Range("H10").Formula = s1

worked fine for me. This isn't an array formula, so you don't need
formulaArray

--
Regards,
Tom Ogilvy


" wrote:

i am writing a macro and would like to insert a formula in like this

Range("H10").FormulaArray =
"=IF((WEEKDAY(DATE(YEAR(H9)+$D$1,MONTH(H9)+$D$2,DA Y(H9)+$D$3),1)-1)*(WEEKDAÂ*Y(DATE(YEAR(H9)+$D$1,MONTH(H9)+$D$2,DA Y(H9)+$D$3),1)-7)=0,WORKDAY(DATE(YEARÂ*(H9)+$D$1,MONTH(H9)+$D$2,D AY(H9)+$D$3),-1),DATE(YEAR(H9)+$D$1,MONTH(H9)+$D$Â*2,DAY(H9)+$D$ 3))"



the formula works fine.. but the '=' sign inside the quotes is causing
some problems


how do i overcome this.
basically i am trying to add one month to a date. if the result is not
a weekday, then, i shift the result to one previous weekday

thanks a lot in advance


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default insert formula


Seems to me like you're using an unnecessarily complex formula. This
should achieve the same

=WORKDAY(DATE(YEAR(H9)+$D$1,MONTH(H9)+$D$2,DAY(H9) +$D$3+1),-1)

...although I'm not sure what's in D1, D2 and D3. If you're just adding
one month to the date, as you say then aren't D1 and D3 zero?


--
daddylonglegs
------------------------------------------------------------------------
daddylonglegs's Profile: http://www.excelforum.com/member.php...o&userid=30486
View this thread: http://www.excelforum.com/showthread...hreadid=542934

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
trying to insert a formula davegb Excel Programming 3 April 25th 06 08:45 PM
Insert a value into formula Ed Excel Discussion (Misc queries) 5 April 16th 06 06:25 AM
How to insert = in formula bar Tirtha Raj Adhikari Excel Discussion (Misc queries) 1 September 14th 05 09:02 AM
insert formula [email protected] Excel Programming 1 August 16th 05 07:27 PM
Insert Formula Kevin Excel Programming 4 September 10th 04 04:56 PM


All times are GMT +1. The time now is 04:10 AM.

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"