Results 1 to 3 of 3

Looping Until Matches Date

Threaded View

  1. #1
    Registered User
    Join Date
    03-28-2013
    Location
    South Africa
    MS-Off Ver
    Excel 2007
    Posts
    8

    Looping Until Matches Date

    Hi,

    I am new to VBA programming and have tried to create a loop that copy and pastes values from right to left. The StartDate is in the copy and paste section I am copying and pastesing repeatedly. The CurrentDate is at the top of my spreadsheet. There are different dates that are at the top of the sheet every 10 or 11 columns on the top row

    So what I am having a problem with is I want the Activecell.offset to work on what the loop pastes to then check the CurrentDate on the top row above. What it is currently doing is just referring to the CurrentDate at the top at the start of the loop but not moving along with the pasting of the data and then lookup up to top row above where it is when it pastes the lasted loop.

    So lets say the "StartDate" is 10/10/2012 at the top "CurrentDate" it has the dates from around 07/07/2018 and is at the top row all the way back to 02/02/2002 so along the way the "StartDate" will match the "CurrentDate" and it should stop looping.

    Hope I am making sense. Below is my attempt which is not working.

    Sub CopyPasteLoop()
    
    StartDate = ActiveCell.Offset(29, -2).Range("A1").Value
    CurrentDate = ActiveCell.Offset(-160, -5).Range("A1").Value
        
        ActiveCell.Offset(0, -10).Range("A1:J32").Select
        Selection.Copy
        ActiveCell.Offset(0, 10).Range("A1").Select
        
    Do
        ActiveCell.Offset(0, -10).Range("A1").Select
        ActiveSheet.Paste
    
    Loop Until StartDate = CurrentDate
    
    End Sub
    Last edited by jeffreybrown; 09-18-2018 at 11:49 AM. Reason: Please use code tags!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] If date matches and room matches, return room info in to cell
    By HonorBray in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 03-12-2018, 12:09 PM
  2. Help with looping through index function to get all matches in vba
    By kpaull in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-08-2016, 12:49 PM
  3. [SOLVED] find date that matches date on my sheet and copy from table below.
    By k1989l in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 06-07-2016, 08:02 AM
  4. Replies: 9
    Last Post: 10-08-2015, 01:50 PM
  5. Replies: 8
    Last Post: 03-07-2014, 03:12 PM
  6. [SOLVED] Codes for looping thru all file when matches found
    By cokillerliu in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-06-2013, 11:29 PM
  7. Mark cell if location matches and date falls between date range
    By DoodlesMama in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-24-2012, 07:54 PM

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1