Consulting

Results 1 to 2 of 2

Thread: How to determine 7 calendar days?

  1. #1
    VBAX Regular
    Joined
    Nov 2015
    Posts
    43
    Location

    How to determine 7 calendar days?

    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
    Attached Files Attached Files

  2. #2
    VBAX Regular
    Joined
    Nov 2015
    Posts
    43
    Location
    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
    Last edited by Aussiebear; 12-13-2015 at 03:09 PM. Reason: added hash tag to code

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •