» List and add the days of months in a set period using VBA in Microsoft Excel
CATEGORY - Date & Time in VBA
VERSION - All Microsoft Excel Versions
How are the days of a month listed and added into a Worksheet proceeding from a Start- and End date with the current name of the month?
Answer:
Enter the following Code with Excel5/7 in an English-language, with Excel8 in a general Module, assign it to a Button and run it.
Place the code below into the standard module
Sub Days()
Dim sngCounter As Single
Dim intRow As Integer, intDays As Integer
Columns("D:E").ClearContents
sngCounter = Range("B1")
Do
intDays = intDays + 1
If Month(sngCounter) <> Month(sngCounter + 1) Then
intRow = intRow + 1
Cells(intRow, 4) = Format(sngCounter, "mmmm")
Cells(intRow, 5) = intDays
intDays = 0
End If
sngCounter = sngCounter + 1
Loop Until sngCounter > Range("B2")
intRow = intRow + 1
Cells(intRow, 4) = Format(Range("B2"), "mmmm")
Cells(intRow, 5) = Day(Range("B2"))
Cells(intRow + 1, 5) = Application.Sum(Range("E1:E" & intRow))
End Sub
Book Store:
Recommended Books:
- The McGraw-Hill 36-Hour Course in Finance for Nonfinancial Managers
- Microsoft PowerPoint Version 2002 Step by Step
- AWAKEN THE GIANT WITHIN : HOW TO TAKE IMMEDIATE CONTROL OF YOUR MENTAL, EMOTIONAL, PHYSICAL AND FINANCIAL
- Keys to Reading an Annual Report (Barron's Business Keys)
- Financial Peace: Revisited
- Investing in Real Estate, Fourth Edition
No comments have been submitted.

