» 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:
- A Mathematician Plays the Stock Market
- Excel Charts
- Investments + S&P Card + Powerweb + StockTrak discount coupon
- Successful Business Planning in 30 Days: A Step-By-Step Guide for Writing a Business Plan and Starting Your Own Business
- The 22 Immutable Laws of Marketing : Exposed and Explained by the World's Two
- Quantitative Methods in Derivatives Pricing: An Introduction to Computational Finance
No comments have been submitted.

