Solved

Change dates in 2 Cells (first and last day of month)

Posted on 2016-09-05
4
30 Views
Last Modified: 2016-09-05
Hi,

I have a sheet where I am constantly changing dates (first and last day of a month). Looking for a way to do this with one click.

Attached is an example of what I am looking for. Whatever month is in the cells, just hit increment or decrement to get the first and last dates for the next (or previous) month.

Thanks in advance,

swjtx99
DateExample.xlsx
0
Comment
Question by:swjtx99
  • 3
4 Comments
 
LVL 29

Accepted Solution

by:
Subodh Tiwari (Neeraj) earned 500 total points
ID: 41785134
Please try something like this.....

Sub IncrementMonth()
Range("F1").Value = WorksheetFunction.EDate(Range("F1").Value, 1)
Range("F2").Value = WorksheetFunction.EoMonth(Range("F2").Value, 1)
End Sub

Sub DecrementMonth()
Range("F1").Value = WorksheetFunction.EoMonth(Range("F1").Value, -2) + 1
Range("F2").Value = WorksheetFunction.EoMonth(Range("F2").Value, -1)
End Sub

Open in new window

DateExample.xlsm
0
 
LVL 29

Expert Comment

by:Subodh Tiwari (Neeraj)
ID: 41785137
For IncrementMonth, you can also use the following code....

Sub IncrementMonth()
Range("F1").Value = WorksheetFunction.EoMonth(Range("F1").Value, 0) + 1
Range("F2").Value = WorksheetFunction.EoMonth(Range("F2").Value, 1)
End Sub

Open in new window

0
 

Author Closing Comment

by:swjtx99
ID: 41785181
Worked Great!

Thanks again Subodh!

swjtx99
0
 
LVL 29

Expert Comment

by:Subodh Tiwari (Neeraj)
ID: 41785496
You're welcome. Glad to help.
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This Article briefly covers methods of calculating the NPV and IRR variants in Excel as well as the limitations in calculating and interpreting IRR results. Paraphrasing Richard Shockley, author of my favourite finance reference tex…
Improved? Move/Copy Add-in Replacement - How to avoid the annoying, “A formula or sheet you want to move or copy contains the name XXX, which already exists on the destination worksheet.” David Miller (dlmille)  It was one of those days… I wa…
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now