Function in Excel

  • Thread starter Thread starter michaelsdumas
  • Start date Start date
M

michaelsdumas

I am looking to use a function in VBA like =DATE(YEAR(NOW())-1,MONTH
(NOW()),DAY(NOW()))

How can I do this?

I tried: Application.WorksheetFunction.Date(Year(Now()) - 1, Month(Now
()), Day(Now())) without success.

Thanks.
 
I am looking to use a function in VBA like =DATE(YEAR(NOW())-1,MONTH
(NOW()),DAY(NOW()))

How can I do this?

I tried: Application.WorksheetFunction.Date(Year(Now()) - 1, Month(Now
()), Day(Now())) without success.

Thanks.

Michael,

Use DateSerial.

Best,

Matthew Herbert

Dim myDate As Date
myDate = DateSerial(Year(Date) - 1, Month(Date), Day(Date))
 
Back
Top