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.
 
Hi,

Try this

mynewtime = Format(DateAdd("yyyy", -1, Now), "dd/mm/yyyy")

Mike
 
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))
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top