Hi, I have a sheet with a string of date, 365 lines long as below..
03/01/2016 Sunday 1
04/01/2016 Monday 2
05/01/2016 Tuesday 3
.
.
.
I am trying to write a bit of code to manipulate the sheet so that it inserts a line at the start of every month, and in column A of that row it puts the Name (in text) of the month following, so i end up with:
January
03/01/2016 Sunday 1
.
.
etc
so far i have:
Sub monthdef()
Dim month As Variant
Dim R As Range
month = Range("a2").Value
MsgBox month
For Each R In Range("c2:c367")
If R.Value = 1 Then
rows(R.Row).Select
Selection.Insert shift = xlDown
Range("a" & R.Row - 1).Select
ActiveCell.Value = month
Range("c" & R.Row + 15).Select
month = month + 32
MsgBox month
End If
Next R
End Sub
but this cant 'jump' the first 1 it comes to! and I don't know the code to get the text value of month into the row eiether.
Can you help?
Thanks
Andy
03/01/2016 Sunday 1
04/01/2016 Monday 2
05/01/2016 Tuesday 3
.
.
.
I am trying to write a bit of code to manipulate the sheet so that it inserts a line at the start of every month, and in column A of that row it puts the Name (in text) of the month following, so i end up with:
January
03/01/2016 Sunday 1
.
.
etc
so far i have:
Sub monthdef()
Dim month As Variant
Dim R As Range
month = Range("a2").Value
MsgBox month
For Each R In Range("c2:c367")
If R.Value = 1 Then
rows(R.Row).Select
Selection.Insert shift = xlDown
Range("a" & R.Row - 1).Select
ActiveCell.Value = month
Range("c" & R.Row + 15).Select
month = month + 32
MsgBox month
End If
Next R
End Sub
but this cant 'jump' the first 1 it comes to! and I don't know the code to get the text value of month into the row eiether.
Can you help?
Thanks
Andy