PDA

View Full Version : How to determine 7 calendar days?



pivotguy
12-11-2015, 07:52 AM
I have input sheet containing dates . I would like to find out what is the 7 calendar days from that input days.
The output file have all other attributes exactly same as input file, except the date. This can not be done manually
because the original file contains ~600 records. Any suggestion .


See the attached file contain 2 sample records.




Input
=====
Perform Name--> engine#-->Date-->system
=======================================
David Smith---->ACB098-->2/10/2015-->Laptop


OUTPUT
======
Perform Name--> engine#-->Date-->system
========================================
David Smith---->ACB098-->2/10/2015-->Laptop
David Smith---->ACB098-->2/9/2015-->Laptop
David Smith---->ACB098-->2/8/2015-->Laptop
David Smith---->ACB098-->2/7/2015-->Laptop
David Smith---->ACB098-->2/6/2015-->Laptop
David Smith---->ACB098-->2/5/2015-->Laptop
David Smith---->ACB098-->2/4/2015-->Laptop

pivotguy
12-11-2015, 08:31 AM
This issue is resolved.


Sub Test()
Application.ScreenUpdating = False
Dim LastRow As Long
LastRow = Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
Dim rDate As Range
Dim x As Long
For Each rDate In Range("C2:C" & LastRow)
For x = 0 To 6
Range("A" & rDate.Row & ":B" & rDate.Row).Copy Sheets("Output").Cells(Rows.Count, "A").End(xlUp).Offset(1, 0)
Sheets("Output").Cells(Rows.Count, "C").End(xlUp).Offset(1, 0) = rDate - x
Sheets("Output").Cells(Rows.Count, "D").End(xlUp).Offset(1, 0) = rDate.Offset(0, 1)
Next x
Next rDate
Application.ScreenUpdating = True
End Sub