![]() |
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 |
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 |
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 |
All times are GMT +1. The time now is 10:11 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com