VBA Error

Hi,

I have this code in the VBA Editor

ActiveCell.FormulaR1C1 = "=DATE(YEAR(Update!AB1),MONTH(Update!AB1),0)"

It produces an error in excel, the formula it drops out is

=DATE(YEAR(Update!'AB1'),MONTH(Update!'AB1'),0)

I notice if i take the apostrophes away from AB1, the formula works, how can i fix this in the editor?

Thanks
Seamus
Seamus2626Asked:
Who is Participating?
 
Ingeborg Hawighorst (Microsoft MVP / EE MVE)Connect With a Mentor Microsoft MVP ExcelCommented:
Hello,

Don't use the ActiveCell.FormulaR1C1 if you reference cells with the A1 style. Instead use

ActiveCell.Formula = "=DATE(YEAR(Update!AB1),MONTH(Update!AB1),0)"

and the formula in the cell will be fine.

cheers, teylyn
0
 
jppintoConnect With a Mentor Commented:
Put .Formula instead, like this:

ActiveCell.Formula= "=DATE(YEAR(Update!AB1),MONTH(Update!AB1),0)"

0
 
Seamus2626Author Commented:
Thanks guys
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.