EDATE problem

0 Agios

Well-known Member
Joined
Feb 22, 2004
Messages
570
Office Version
  1. 365
what i want to do is add a new month, so if the previous cell says Aug 23 the new one should say Sept 23
this is my code and a sample of the page


Private Sub CommandButton1_Click()
ActiveCell.EntireColumn.Select
ActiveCell.EntireColumn.Copy ActiveCell.Offset(0, 3).EntireColumn
Selection.Copy
ActiveCell.Offset(0, 1).ColumnWidth = 1
ActiveCell.Offset(0, 2).PasteSpecial Paste:=xlPasteAll
ActiveCell.Offset(0, 0) = "=EDATE(R[-3]C,0)"
End Sub
1693247463449.png
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
How would we know what the ActiveCell is?
 
Upvote 0
yes that's not the problem, if i use the formula +1 it does it for days only
 
Upvote 0
if i use the formula +1 it does it for days only
Why are you talking about +1? :confused:

You said that if the original column said Aug-23 then the new column should be Sep-23. That is exactly what the code does for me if you remove your incorrect formula and replace it with the one suggested in post #2. I am assuming that the original yellow merged cell contains an actual date formatted to show month & year only.

Here is my sheet before the code

0 Agios.xlsm
ABCDEFG
1Aug-23
2PROJECTS
3a1
4b2
5c3
6d4
7
Sheet2


And after:

0 Agios.xlsm
ABCDEF
1Aug-23Sep-23
2PROJECTSPROJECTS
3a1a1
4b2b2
5c3c3
6d4d4
7
Sheet2
Cell Formulas
RangeFormula
D1D1=EDATE(A1,1)


Isn't that what you wanted?
 
Upvote 0
gives me "NAME"
ActiveCell.Offset(0, 0).Value = "=EDATE(ActiveCell.Offset(-3, 0), 1)"

1693320203213.png
 
Upvote 0

Forum statistics

Threads
1,215,107
Messages
6,123,127
Members
449,097
Latest member
mlckr

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top