Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
hello,
What statement would I use to find out maximun days in a month in VBA? Thanks in advance |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
James,
Months in VBA are the same as regular months, so 31. But I'm guessing your question is somewhat more specific than it appears. What kind of days? Workdays? Weekend days? Odd numbered Wednesdays? HTH, Bernie MS Excel MVP "james" wrote in message ... hello, What statement would I use to find out maximun days in a month in VBA? Thanks in advance |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
the zeroth day of the next month is the last days of the month in question
Dim dt as Date dt = Date lastDay = days(DateSerial(year(dt),Month(dt)+1,0)) -- Regards, Tom Ogilvy "james" wrote in message ... hello, What statement would I use to find out maximun days in a month in VBA? Thanks in advance |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Here is a demo:
Sub ABCD() sStr1 = "" For i = 1 To 12 dt = DateSerial(2005, i, 1) sStr = "Last day of " & _ Format(dt, "mmmm") & " is " & _ Day(DateSerial(Year(dt), Month(dt) + 1, 0)) sStr1 = sStr1 & sStr & vbNewLine Next MsgBox sStr1, , "Last Day of the Month for Year 2005" End Sub -- Regards, Tom Ogilvy "Tom Ogilvy" wrote in message ... the zeroth day of the next month is the last days of the month in question Dim dt as Date dt = Date lastDay = days(DateSerial(year(dt),Month(dt)+1,0)) -- Regards, Tom Ogilvy "james" wrote in message ... hello, What statement would I use to find out maximun days in a month in VBA? Thanks in advance |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
Lat day in a month i given by Dim d as Date d=date() '<--- your date here 'last date of month msgbox MonthLastDay = DateSerial(Year(d), Month(d) + 1, 1 - 1) 'day number msgbox Day(MonthLastDay = DateSerial(Year(d), Month(d) + 1, 1 - 1)) Regards, Sebastienm "james" wrote: hello, What statement would I use to find out maximun days in a month in VBA? Thanks in advance |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
okj, i'll try to re-write my previous post without error this time:
Dim d as Date d=date() '<--- your date here 'last date of month msgbox DateSerial(Year(d), Month(d) + 1, 1 - 1) 'day number msgbox Day(DateSerial(Year(d), Month(d) + 1, 1 - 1)) sebastienm |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Note that days should be signular
lastDay = days(DateSerial(year(dt),Month(dt)+1,0)) should be lastDay = day(DateSerial(year(dt),Month(dt)+1,0)) sorry for the typo. -- Regards, Tom Ogilvy "Tom Ogilvy" wrote in message ... the zeroth day of the next month is the last days of the month in question Dim dt as Date dt = Date lastDay = days(DateSerial(year(dt),Month(dt)+1,0)) -- Regards, Tom Ogilvy "james" wrote in message ... hello, What statement would I use to find out maximun days in a month in VBA? Thanks in advance |
#8
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
On Mon, 7 Feb 2005 11:05:02 -0800, "james"
wrote: hello, What statement would I use to find out maximun days in a month in VBA? Thanks in advance You don't have to compute it since VBA uses the same calendar. ==================== Const MaxDaysInMonth As Integer = 31 ==================== Perhaps you mean something else? --ron |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
excel to make the days cary over month to month automaticly | New Users to Excel | |||
Number of days in month counted from shortened name of month & yea | Excel Worksheet Functions | |||
Days per month for calculating storage days | Excel Worksheet Functions | |||
function to fill all days of month to end of month | Excel Worksheet Functions | |||
formula for days in month - days left??? | Excel Programming |