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
Bookmarks