Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Increment a cell containg a name of a month using vba 1

Status
Not open for further replies.

A10Instructor

Technical User
Feb 7, 2005
27
US
Hello,

I have an excel worksheet that has a cell (A4) that contains the text 'AUGUST'. I wish to use a macro, that when ran, reads the contents of cell A4 and then replacees the contents with the next month. For example, if cell A4 currently states AUGUST, when macro is ran, cell A4 will now state SEPTEMBER.

Any ideas on how to do this? I have had no luck so far?

Thanks and any help will be greatly appreciated.

A10 Instructor
"The World is My Classroom
 


Hi,

Put a REAL DATE in A4, for instance 8/1/2005.

Then incriment the month...
Code:
iMonInc = 1
With [A4]
  .Value = dateserial(Year(.value),Month(.Value)+iMonInc,Day(.Value)
ENd with


Skip,

[glasses] [red]A palindrome gone wrong?[/red]
A man, a plan, a ROOT canal...
PULLEMALL![tongue]
 


Oh, BTW

Format A1 as "mmmm"

Why do Dates and Times seem to be so much trouble? faq68-5827

Skip,

[glasses] [red]A palindrome gone wrong?[/red]
A man, a plan, a ROOT canal...
PULLEMALL![tongue]
 
Skip,

Thank you very much for the quick response and the suggested code. It worked like a champ.

Thanks a whole bunch

A10 Instructor
"The World is My Classroom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top