Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 542
Default maximum days in a month

hello,
What statement would I use to find out maximun days in a month in VBA?

Thanks in advance
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default maximum days in a month

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default maximum days in a month

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default maximum days in a month

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 694
Default maximum days in a month

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 694
Default maximum days in a month

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default maximum days in a month

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,651
Default maximum days in a month

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
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 to make the days cary over month to month automaticly GARY New Users to Excel 1 April 19th 08 06:05 PM
Number of days in month counted from shortened name of month & yea Tumar Excel Worksheet Functions 6 September 18th 07 03:36 PM
Days per month for calculating storage days Bart Excel Worksheet Functions 3 January 31st 07 06:40 PM
function to fill all days of month to end of month YaHootie Excel Worksheet Functions 10 May 1st 06 06:01 AM
formula for days in month - days left??? Jason[_18_] Excel Programming 3 August 23rd 03 09:58 PM


All times are GMT +1. The time now is 02:05 AM.

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"