Add one month to all the date...

Closed
fireburn Posts 27 Registration date Monday 3 February 2014 Status Member Last seen 23 June 2014 - 2 May 2014 à 13:49
 Blocked Profile - 5 May 2014 à 09:24
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 responses

Blocked Profile
2 May 2014 à 18:07
OK hang in there.....


So what part are stuck with?

Where does the pasted code fail?
Blocked Profile
2 May 2014 à 19:39
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!

fireburn Posts 27 Registration date Monday 3 February 2014 Status Member Last seen 23 June 2014
3 May 2014 à 00:11
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
3 May 2014 à 11:12
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.
Blocked Profile
5 May 2014 à 09:24
I see you have posted again. I am closing this thread. You could always just add 31 to the cell!