I have opened another sheet called sheet2 where I copied the data form column A and B from sheet called "existing".
I made the sheset2 as active sheet.(you need not do it. the macro does it)
now run the macro "test"
Sub test()
Dim j As Integer, k As Integer, m As Integer
j = Range("A1").End(xlDown).Row
Worksheets("sheet2").Activate
For k = j To 3 Step -1
'If Cells(k - 1, "A") = Cells(k, "A") - TimeSerial(0, 0, 20) Then GoTo nextk
'MsgBox k
m = Round((Cells(k, "A") - Cells(k - 1, "a")) / (20 / 60 / 60 / 24))
'MsgBox m
If m = 1 Then GoTo nextk
Range(Cells(k, "A"), Cells(k + m - 2, "A")).EntireRow.Insert
Range(Cells(k - 1, "A"), Cells(k + m - 2, "A")).DataSeries rowcol:=xlColumns, Type:=xlLinear, Date:=xlDay, _
Step:=TimeSerial(0, 0, 20), Trend:=False
Range(Cells(k - 1, "B"), Cells(k + m - 2, "B")).FormulaArray = Cells(k - 1, "B").Value
nextk:
Next k
MsgBox "macro over"
End Sub
after running the macro I copied the columns A and B from sheet "required" and pasted it on C1 in sheet2 so that you can compare the result of the macro and required
your file now called "book 2 ANANTH.xls" is returned.
If you want to recheck the macro
do this "undo" macro given below
Sub undo()
Worksheets("sheet2").Cells.Clear
Worksheets("existing").Cells.Copy
Worksheets("sheet2").Range("A1").PasteSpecial
Application.CutCopyMode = False
End Sub
after re running the macro you again copy columns A and B from sheet "required" and paste it to D1 of sheet2 for verifying .
As you are messing up with data keep the sheet "existing" as it is and do the macro on sheet 2 so that the original data can be retrieved if there is a problem.,
your feedback please
Bookmarks