Range("J4").Select
ActiveCell.FormulaR1C1 = "=text(B4, "yyyy")"
Range("B3").Select
I get an error which reads: Compile error:
--
Linda
"mathel" <mat...@discussions.microsoft.com> wrote in message
news:AF17F22B-8CFE-4597...@microsoft.com...
Thanks for the quick response.
--
Linda
I input the line exactly as shown below, then run my macro. The results I
get are the cell shows: #NAME?
When I look at the actual formula it appears as: =YEAR('B4').
How do I get rid of the single quote around B4?
Thanks
--
Linda
Try using Activecell.Formula instead.
--
Dave Peterson
Range("B4").Select
ActiveCell.FormulaR1C1 = "=TODAY()"
Range("J4").Select
ActiveCell.Formula = "=YEAR(B4)"
As stated, this gives me a result of 1905 in cell J4.
Thanks for your help
--
Linda
Range("J4").Select
ActiveCell.Formula = "=YEAR(B4)"
I was getting the result of 1905. I have now formatted the cell as number
and now get the correct response.
Thanks for all you assistance.
Linda
You can accomplish the same kind of thing without the .select's:
Range("B4").FormulaR1C1 = "=TODAY()"
Range("J4").Formula = "=YEAR(B4)"
or even
with worksheets("Somesheetnamehere")
.Range("B4").Formula = "=TODAY()"
with .range("J4")
.numberformat = "General"
.Formula = "=YEAR(B4)"
end with
end with
--
Dave Peterson