?
Solved

Advance date by one month

Posted on 2008-10-19
6
Medium Priority
?
202 Views
Last Modified: 2013-11-25
Is there a VBA code that can look to a cell with a date entered in text format "Sep-07" for example and automatically change it to the next month in text format "Oct-07".  Then when it sees "Dec-07" it will change the datge to "Jan-08"?  The text format is iimportant because other cells refer to the date in text format to retrieve data.
0
Comment
Question by:ronadair
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
6 Comments
 
LVL 59

Expert Comment

by:Saurabh Singh Teotia
ID: 22752625
What exactly you want to do...???

Saurabh...
0
 
LVL 59

Accepted Solution

by:
Chris Bottomley earned 1000 total points
ID: 22752762
You can replace activecell with a specific address but try:

ActiveCell.Value = DateAdd("m", 1, ActiveCell)

Chris
0
 

Author Comment

by:ronadair
ID: 22752792
Chris -

I added the code, but it advanced the date to 10/7/2008.  I need it to advance one month and maintain text format to read Oct-08.

Ron
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 59

Assisted Solution

by:Saurabh Singh Teotia
Saurabh Singh Teotia earned 1000 total points
ID: 22752804
A few changes in the chris code will do what you want...which is...

ActiveCell.Value = format(DateAdd("m", 1, ActiveCell),"mmm-yy")

Saurabh...
0
 

Author Closing Comment

by:ronadair
ID: 31507608
Thanks to each of you.  Worked like a charm!
0
 
LVL 59

Expert Comment

by:Chris Bottomley
ID: 22752854
Your welcome, thanks for the quick response ... I was about to post a change to ensure the correct number format of the cell but Saurab's way is good as well ... there being many ways to the same end.

Chris
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

777 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