Solved

Advance date by one month

Posted on 2008-10-19
6
196 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
  • 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 250 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
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
LVL 59

Assisted Solution

by:Saurabh Singh Teotia
Saurabh Singh Teotia earned 250 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.

828 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