Add one month to all the date... [Closed]

Report
Posts
28
Registration date
Monday February 3, 2014
Status
Member
Last seen
June 23, 2014
-
 Blocked Profile -
Hello,

Sub Sample()
Dim ws As Worksheet
Dim lRow As Long, i As Long

'~~> Change this to the relevant sheet
Set ws = ThisWorkbook.Sheets("Sheet1")

With ws
lRow = .Range("A" & .Rows.Count).End(xlUp).Row

For i = 3 To lRow
.Range("A" & i).Value = DateAdd("m", 1, .Range("A" & i).Value)
Next i
End With
End Sub

Can somebody help me with this code to add one month to all the sheets in column A in my workbook.

Code from this site <--REMOVED FOR SPAM-->

3 replies


OK hang in there.....


So what part are stuck with?

Where does the pasted code fail?

Look if you are going to cut and paste scripts/macros/vbscripts....

....please understand how to reverse engineer the code at least.....

...at this point you have earned yourself the title of......

[HORNS BLOW AND A BUNCH OF FANFAIR]

SCRIPTKIDDI3!

You must qualify your variables as follows, according to th3 script you cut....

Setting Description
yyyy Year
q Quarter
m Month
y Day of year
d Day
w Weekday
ww Week
h Hour
n Minute
s Second


there really isn't a single programmer that will make it easy (for another programmer)!

Try some stuff and let us know where you are stuck!

Posts
28
Registration date
Monday February 3, 2014
Status
Member
Last seen
June 23, 2014

Hi,

I am not a programmer and dont know VB just doing it for some Seniors home stuff to make things easier. I am nurse.

I tried some to "reverse engineering" but i dont know how to code that it will be applied to all the column A in all my workbook. Because this code only applies to Sheet 1 in column A.

I know i can do copy paste the code in every sheet, but the thing is I have more than 50 sheets in a workbook.

Thank you.
Blocked Profile
If you are going to use DATEADD() for your solution, it would look like this, ALSO THIS IS FOR EXCEL2013:
http://office.microsoft.com/en-us/excel-help/dateadd-function-dax-HA102838097.aspx
I just returned home and my home version does not have it.
=DateAdd(A1,1,month)
fill in the top cell, and drag it into the rest of the cells.

Or if you are going to continue to use the above VB, then let us know where it fails for you. Try the format I have used above itf it fails.

I see you have posted again. I am closing this thread. You could always just add 31 to the cell!

Subscribe To Our Newsletter!

The Best of CCM in Your Inbox

Subscribe To Our Newsletter!