Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 209
  • Last Modified:

Advance date by one month

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
ronadair
Asked:
ronadair
  • 2
  • 2
  • 2
2 Solutions
 
Saurabh Singh TeotiaCommented:
What exactly you want to do...???

Saurabh...
0
 
Chris BottomleyCommented:
You can replace activecell with a specific address but try:

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

Chris
0
 
ronadairAuthor Commented:
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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
Saurabh Singh TeotiaCommented:
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
 
ronadairAuthor Commented:
Thanks to each of you.  Worked like a charm!
0
 
Chris BottomleyCommented:
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!

  • 2
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now