We help IT Professionals succeed at work.

# Insert Formula with VBA error

on
I have the following formula that i am inserting with vba (it is part of a much bigger macro)

Columns("D:D").Select
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
Range("D1:D5000").Formula = _
"=DATE(1970,1,1)+D1/86400)"

when it runs (it is all OK) until it gets to the inserting the formula then i get an error. cant see where I am going wrong ?
Comment
Watch Question

## View Solution Only

Analyst Assistant
Commented:
You've got an extra parenthesis either at the end of the formula or after the date function:

It should be either:

"=DATE(1970,1,1)+D1/864000"

Or

"=DATE(1970,1,1+D1/864000)"

I suppose it depends on what's in D1 and what you are trying to add to the date.

Commented:
of course, couldnt see it for looking!!
Analyst Assistant

Commented:
Which one was it?