Finding Number Of Days in a month
-----Original Message-----
Hi I need to find uot how many days are in a month in
VBA
is there a way of doing this if so can someone help me
please TIA
Charles
.
This probably isn't the best way, but you could run a
Do...Until loop. use two variables as counters. Use the
first counter variable, initialized to the value 1, and
run the loop until the variable is greater than 31 days.
Create a text date value from each value of the first
counter variable [Ex: CurrDate=Month(date)&"/" & counter
& "/" & Year(date)]. Then test to see if the date is
valid, using an If...Then test and the IsDate function
[Ex: if IsDate(CurrDate) then...
If the date is valid, increment the second counter to
keep track of the number of days in the month, increment
the first counter to its next value, and repeat the loop.
if the date isn't valid, exit the loop, and the number of
days in the month will be the value of the second
counter.
|