Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Function in Excel

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.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Function in Excel

Hi,

Try this

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

Mike

" wrote:

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.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 56
Default Function in Excel

On Jul 24, 9:08*am, "
wrote:
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))
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel Data Validation/Lookup function does function correcty Kirkey Excel Worksheet Functions 2 May 25th 09 09:22 PM
copy of excel file not showing formulal/function in the function b oaallam Excel Discussion (Misc queries) 4 September 6th 07 01:20 PM
Excel - User Defined Function Error: This function takes no argume BruceInCalgary Excel Programming 3 August 23rd 06 08:53 PM
Adding a custom function to the default excel function list DonutDel Excel Programming 3 November 21st 03 03:41 PM
When I Import an Access Table With an Excel Function in a Cell it Displays as Text not as a Function in Excel Niek Otten Excel Programming 2 September 18th 03 03:55 AM


All times are GMT +1. The time now is 01:20 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"