dateadd

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

In a macro I would like to add 1 month to a date in another cell. L5 =
3/31/07 so when the macro runs I would like L4 to display 4/30/07. something
like:

Range("L4").Select
ActiveCell. add 1 month to date in L5.

Any ideas??
 
Try the following
Range("L4").value = dateserial(year(L5),month(L5)+1,day(L5))

HTH
 
Sub addmonthtodate()' NO selections
mc = Range("l5")
Range("l4") = DateSerial(Year(mc), Month(mc) + 1, Day(mc))
End Sub
 
This didn't work either. I think because this is being put in the middle of
a larger macro that was expected to end befor I entered Sub again?
 
"Didn't work" means nothing without explanation.
I fully tested. Shouldn't make any difference but you didn't post your code,
so???

mc = Range("l5")
Range("l4") = DateSerial(Year(mc), Month(mc) + 1, Day(mc))
 
Sorry about the lack of clarity. I tried this and it almost did what I
wanted. The date moved from 6/30/06 to 7/30/06 and I tried from 8/31/06 and
it went to 10/01/06. I am looking for it to go to the last day of the month
(ie. 6/30/06 to 7/31/06 and 8/31/06 to 9/30/06).

I appreciate the help on this. Any idea what I can change to get it to work
the way I had hoped?

Thanks
 
Always nice to say what you want the FIRST time.

Sub addmonthtodate() ' NO selections
mc = Range("a1")
Range("i1") = DateSerial(Year(mc), Month(mc) + 2, 1 - 1)
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top