Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 273
Default Advance By Month With A CommandButton

Greetings,

I have a worksheet with a date in C10 in mmm/yyyy formant. I made a
CommandButton (NextMonth) to advance the date by 1 month. I have a
problem, I used +30 to advance which works for the short term.
However, I am going back 12 years and getting a lot of errors in the
date.

Is there anyway to advance by one month at a time?

Any help would be appreciated.

TIA

-Minitman


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 863
Default Advance By Month With A CommandButton

One way:

With ActiveSheet.Range("C10")
.Value = DateAdd("m",1,.Value)
End With

Another way

With ActiveSheet.Range("C10")
d = .Value
.Value = DateSerial(Year(d), Month(d) + 1, Day(d))
End With

On Mon, 25 Oct 2004 13:16:35 -0500, Minitman wrote:

Greetings,

I have a worksheet with a date in C10 in mmm/yyyy formant. I made a
CommandButton (NextMonth) to advance the date by 1 month. I have a
problem, I used +30 to advance which works for the short term.
However, I am going back 12 years and getting a lot of errors in the
date.

Is there anyway to advance by one month at a time?

Any help would be appreciated.

TIA

-Minitman


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Advance By Month With A CommandButton

There is a problem here if the following month has less days (31st Jan + 1
month = 31st Feb, or 2nd Mar), so this formula goes back to the last day of
the previous month. Not perfect but

=DATE(YEAR(C1),MONTH(C1)+1,MIN(DAY(C1),DAY(DATE(YE AR(C1),MONTH(C1)+2,0))))

--

HTH

RP

"Minitman" wrote in message
...
Greetings,

I have a worksheet with a date in C10 in mmm/yyyy formant. I made a
CommandButton (NextMonth) to advance the date by 1 month. I have a
problem, I used +30 to advance which works for the short term.
However, I am going back 12 years and getting a lot of errors in the
date.

Is there anyway to advance by one month at a time?

Any help would be appreciated.

TIA

-Minitman




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Advance By Month With A CommandButton

oops missed the button bit.

--

HTH

RP

"Myrna Larson" wrote in message
...
One way:

With ActiveSheet.Range("C10")
.Value = DateAdd("m",1,.Value)
End With

Another way

With ActiveSheet.Range("C10")
d = .Value
.Value = DateSerial(Year(d), Month(d) + 1, Day(d))
End With

On Mon, 25 Oct 2004 13:16:35 -0500, Minitman

wrote:

Greetings,

I have a worksheet with a date in C10 in mmm/yyyy formant. I made a
CommandButton (NextMonth) to advance the date by 1 month. I have a
problem, I used +30 to advance which works for the short term.
However, I am going back 12 years and getting a lot of errors in the
date.

Is there anyway to advance by one month at a time?

Any help would be appreciated.

TIA

-Minitman




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 273
Default Advance By Month With A CommandButton - Solved

Hey Myrna,

This works great, thanks.

-Minitman


On Mon, 25 Oct 2004 13:53:34 -0500, Myrna Larson
wrote:

One way:

With ActiveSheet.Range("C10")
.Value = DateAdd("m",1,.Value)
End With

Another way

With ActiveSheet.Range("C10")
d = .Value
.Value = DateSerial(Year(d), Month(d) + 1, Day(d))
End With

On Mon, 25 Oct 2004 13:16:35 -0500, Minitman wrote:

Greetings,

I have a worksheet with a date in C10 in mmm/yyyy formant. I made a
CommandButton (NextMonth) to advance the date by 1 month. I have a
problem, I used +30 to advance which works for the short term.
However, I am going back 12 years and getting a lot of errors in the
date.

Is there anyway to advance by one month at a time?

Any help would be appreciated.

TIA

-Minitman


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Dates ... advance 1 Month @ a Time Ken Excel Discussion (Misc queries) 3 February 28th 07 10:14 PM
CommandButton Alvin Hansen[_2_] Excel Programming 3 August 16th 04 06:35 PM
CommandButton chris[_12_] Excel Programming 1 April 15th 04 01:01 AM
CommandButton rwebster3 Excel Programming 0 April 14th 04 08:16 PM
Commandbutton David Fixemer Excel Programming 2 February 25th 04 10:18 PM


All times are GMT +1. The time now is 09:07 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"