Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Laurent M
 
Posts: n/a
Default get the latest day of the previous month

hello,

i have a date variable, and i would like with VBA to get
the latest day from the previous month

many thanks
  #2   Report Post  
Harald Staff
 
Posts: n/a
Default

Function LastPrevDate(Dt As Date) As Date
LastPrevDate = DateSerial(Year(Dt), Month(Dt), 0)
End Function

Sub test()
MsgBox LastPrevDate(Now)
End Sub

HTH. Best wishes Harald

"Laurent M" skrev i melding
...
hello,

i have a date variable, and i would like with VBA to get
the latest day from the previous month

many thanks



  #3   Report Post  
Myrna Larson
 
Posts: n/a
Default

In case you specified VBA because you didn't think you could do it with
worksheet functions, the formula is =DATE(YEAR(TODAY()),MONTH(TODAY()),0)


On Wed, 26 Jan 2005 06:06:27 -0800, "Laurent M"
wrote:

hello,

i have a date variable, and i would like with VBA to get
the latest day from the previous month

many thanks


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
UserForm to select current month or earlier Steve Excel Discussion (Misc queries) 2 January 21st 05 09:41 PM
How to extract month number from month name PM Excel Discussion (Misc queries) 2 January 19th 05 03:07 PM
PivotTable - Count by Month Gigi Excel Worksheet Functions 3 January 1st 05 12:30 PM
Pivot Table - Group by Month - Show Items with no data Dan Reynolds Excel Discussion (Misc queries) 0 November 28th 04 01:01 AM
Insert Month and Year in my worksheet Myrna Excel Worksheet Functions 1 November 8th 04 01:29 AM


All times are GMT +1. The time now is 10:42 AM.

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

About Us

"It's about Microsoft Excel"