Hi Everyone,
I use a spreadsheet where I would like to add on 6 months to the date period in column A. The date period is YYYYMM. I would like to display in column C. I have attached an excel sheet as an example, showing the wrong dates (tab one) and the correct dates (tab two). I have had a go at a macro but its not very good and doesn't work.
Please see below, I would be grateful for some help.
Thanks,
Andy
I use a spreadsheet where I would like to add on 6 months to the date period in column A. The date period is YYYYMM. I would like to display in column C. I have attached an excel sheet as an example, showing the wrong dates (tab one) and the correct dates (tab two). I have had a go at a macro but its not very good and doesn't work.
Please see below, I would be grateful for some help.
Code:
Sub Test()
Dim i As Long, Lr As Long, Cell As Range, Sh1 As Worksheet, K As String
Dim L As Long
Lr = Range("A" & Rows.Count).End(xlUp).Row
Range("B2:B" & Lr).NumberFormat = "@"
For i = 2 To Lr
K = Application.WorksheetFunction.Text(Right(Range("R" & i).Value, 2) * 6, "mmmm")
If Right(Range("R" & i).Value, 2) < 5 Then
L = Range("A" & i).Value
Else
L = Range("A" & i).Value + 1
End If
Range("B" & i).Value = K & " " & L
Next i
End Sub
Thanks,
Andy