Give a try at the following macro; it uses columns B and C  for the results
:

Sub test()
Dim c As Range, Dict, Res As Date, Ctr As Long
Set Dict = CreateObject("scripting.dictionary")
For Each c In [Dates]
    Res = DateSerial(Year(c), Month(c), 1)
    If Not Dict.exists(Res) Then
        Dict.Add Res, Res
    End If
Next c
For Each Item In Dict
    Ctr = Ctr + 1
    Cells(Ctr, 2) = Format(Item, "mm/yyyy")
    Cells(Ctr, 3) = "=sumproduct((" & [Dates].Address & ">=""" & Item & _
    """*1)*(" & [Dates].Address & "<""" & DateSerial(Year(Item), Month(Item)
+ 1, 1) & _
    """*1))"
Next
End Sub

Regards.
Daniel

> -----Original Message-----
> From: excel-macros@googlegroups.com [mailto:excel-
> mac...@googlegroups.com] On Behalf Of faheem3
> Sent: mercredi 15 juillet 2009 19:16
> To: MS EXCEL AND VBA MACROS
> Subject: $$Excel-Macros$$ Count days in a month
> 
> 
> I have a set of dates in a column say {dates} and they go from today until
> 1/1/2000 (for example).  I want to write a macro/vba to count the # of
days in
> each month.
> 
> I went through manually and checked the cells that were for the beginning
> /ending of the months and wrote:
> 
> 
> =COUNTIFS(dates,"<11/1/2008",dates,">9/30/2008")
> 
> is there a way to do with vba?
> 
> 
> 
> > 




--~--~---------~--~----~------------~-------~--~----~
----------------------------------------------------------------------------------
Some important links for excel users:
1. Excel and VBA Tutorials(Video and Text), Free add-ins downloads at 
http://www.excelitems.com
2. Excel tutorials at http://www.excel-macros.blogspot.com
3. Learn VBA Macros at http://www.vbamacros.blogspot.com
4. Excel Tips and Tricks at http://exceldailytip.blogspot.com
 

To post to this group, send email to excel-macros@googlegroups.com
If you find any spam message in the group, please send an email to:
Ayush Jain  @ jainayus...@gmail.com or
Ashish Jain @ 26may.1...@gmail.com
<><><><><><><><><><><><><><><><><><><><><><>
HELP US GROW !!

We reach over 5,000 subscribers worldwide and receive many nice notes about the 
learning and support from the group. Our goal is to have 10,000 subscribers by 
the end of 2009. Let friends and co-workers know they can subscribe to group at 
http://groups.google.com/group/excel-macros/subscribe
-~----------~----~----~----~------~----~------~--~---

Reply via email to