Hello Everyone!
Kindly refer to http://www.excelforum.com/excel-prog...r-methods.html
When i run following code on the worksheet i attached, it produces correct results, i.e. replacing the whole dates with only "Day" for whole column untill lastrow.
But, it reduces the "Day" by 1 in "Posting Date" column each time when i run the code again.
For example after running the code for first time if the value was "1", running it for 2nd time produces 31, running it again would bring 30, and so on.
Why is it reducing the value by 1 each time?
Sub abc_1()
Dim i As Long, rws As Long, tbl
With Sheets("Sheet1")
rws = .Cells(.Rows.Count, "D").End(xlUp).Row
tbl = .Range("D2:D" & rws).Value
End With
rws = rws - 1
For i = 1 To rws
tbl(i, 1) = Day(tbl(i, 1)) 'Format(tbl(i, 1), "d")
Next
With Sheets("Sheet1").Range("D2:D" & rws + 1)
.NumberFormat = "General"
.Value = tbl
End With
tbl = Empty
End Sub
I am also attaching the sheet.
Thanking in advance
Bookmarks