View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
PaulD PaulD is offline
external usenet poster
 
Posts: 92
Default WS formula for Julian date not converting well to VBA??

"Ed" wrote in message
...
: I found the formula on Chip Pearson's site for converting a date to a
Julian
: date. When I try to use it as a VBA-inserted formula, it's not working
out.
: I keep getting an error message telling me "Expected: a close parenthesis
: after the second YEAR". But doing that doesn't work. Can someone point
me
: to my error?
:
: ws.Range("E1").Formula = "AR"& RIGHT(YEAR(Range("B1")),2)&
: TEXT(Range("B1")-DATE(YEAR(Range("B1")),1,0),"000")
:
: TIA
: Ed
:

Ed,
Chips formula is meant to be pasted directly into a cell. To mimic this
from VBA you need to slightly modify

ws.Range("E1").Formula = "= ""AR"" & RIGHT(YEAR(B1),2) &
TEXT(B1-DATE(YEAR(B1),1,0),""000"")"

Note the double quotes and don't use range as this is VBA code and not
needed for a formula in a cell

Paul D