Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6900181
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T07:30:51+00:00 2026-05-27T07:30:51+00:00

I am working in a excel macro. In that I need to generate all

  • 0

I am working in a excel macro. In that I need to generate all the dates belong to a particular month. Can anybody say how to achieve that?

UPDATE:
I want to receive it as an array of numbers. I tried to use Date related function which were under namespace “System”. But, it is showing error as “object or method not found”. So, I am using Issan’s idea(see below). But, I am getting error as “Object doesn’t support this property or method”.

EDIT:
The “Object doesn’t support this property or method” error went out after I declared a variable as Date. I think the available objects in VBA are depend on declared variables. Thank you to all of you.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T07:30:52+00:00Added an answer on May 27, 2026 at 7:30 am

    (Assuming you meant VBA since you say you are ‘working in an Excel macro’)

    Here’s how you can generate an array of Dates for each day in a particular month (there’s not enough info to suggest what format you want so I am assuming an array of dates).

    Sub GenerateDates()
    
    Dim Days() As Date
    Dim DaysInMonth As Long, i As Long
    Dim Year As Long, Month As Long
    
    ' Example: Feb, 2006 (leap year)
    Year = 1996
    Month = 2
    
    DaysInMonth = DateSerial(Year, Month + 1, 1) - _
                  DateSerial(Year, Month, 1)
    
    ReDim Days(1 To DaysInMonth)
    For i = 1 To DaysInMonth
        Days(i) = DateSerial(Year, Month, i)
    Next
    
    'Do as you wish with the array of 29 days
    
    End Sub
    

    How it works:
    You can get the number of days in a month using the dateserial math above. This will ensure that you get the proper amount of days, even considering leap years. Then you just redim your array of days and populate the array!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working with Excel 2010. I need to create a macro, that after
I am working on a Excel 2007 workbook that will contain a macro to
hi i am working with c# and excel-2007... i wanted to add a macro
I am working on an Excel application that queries a SQL database. The queries
1) I have been working on fetching data from an excel sheet i can
I need to create a Excel 2010 macro, which changes the SQL Command text
How can I automatically execute an Excel macro each time a value in a
I have an Excel file that has a bunch of VBA and macro code
I'm working on a function in Excel that will allow me to sum columns
I have an working Excel file, with file I can send data extracted from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.