PDA

View Full Version : [SOLVED:] Macros - dates in a column and display months in another column



k0st4din
02-19-2014, 09:51 AM
Hello everyone,
please someone for some help - I wrote in another forum, but so far no one answering my query.
I would like to ask you if there is a way to make a macro in a workbook that checks every sheet date in columns (D), and depending on the month in column (V - I written months) and in column (W) months after this month. By completing only for cells in which there is nothing written, if already written months and not change them and thus to the end.
Link to download (http://www.sendspace.com/file/r6swm6) sample.





D



V
W



2.2.2014



February
March



25.2.2014



February
March



14.3.2014



March
April



24.3.2014



March
April



11.1.2014



January
February



18.1.2014



January
February



and down








Friends, that's what I need to get.

Bob Phillips
02-19-2014, 10:02 AM
Sub AddMonths()
Dim ws As Worksheet
Dim lastrow As Long
Dim i As Long

Application.ScreenUpdating = False

For Each ws In ActiveWorkbook.Worksheets

With ws

lastrow = .Cells(.Rows.Count, "D").End(xlUp).Row
For i = 2 To lastrow

If IsDate(.Cells(i, "D").Value) And .Cells(i, "V").Value = "" Then

.Cells(i, "V").Value = Format(.Cells(i, "D").Value, "mmmm")
.Cells(i, "W").Value = Format(.Cells(i, "D").Value - Day(.Cells(i, "D").Value) + 33, "mmmm")
End If
Next i
End With
Next ws

Application.ScreenUpdating = True
End Sub

k0st4din
02-19-2014, 11:37 AM
Many thanks for your quick reaction.