I am trying to get data from Sheet Project_Pipeline Column D1, Match it to Row A1 in the DayView and continue until D1 is empty. I can only get it to copy and paste 1 section of data.
Sub CopyDataToDayView()
Dim LDate As String
Dim LColumn As Integer
Dim LFound As Boolean
Do
On Error GoTo Err_Execute
'Retrieve date value to search for
LDate = Sheets("Project_Pipeline").Range("D1").Value
'Select Dayview
Sheets("DayView").Select
'Start at column B
LColumn = 1
LFound = False
While LFound = False
'Encountered blank cell in row 2, terminate search
If Len(Cells(1, LColumn)) = 0 Then
MsgBox "No matching date was found."
Exit Sub
'Found match in row 2
ElseIf Cells(1, LColumn) = LDate Then
'Select values to copy from "Rolling Plan" sheet
Sheets("Project_Pipeline").Select
Range("C1").Select
Selection.Copy
'Paste onto "DayView" sheet
Sheets("DayView").Select
Cells(2, LColumn).Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
LFound = True
MsgBox "The data has been successfully copied."
Else
LColumn = LColumn + 1
End If
Sheets("Project_Pipeline").Select
Loop Until IsEmpty(ActiveCell.Offset(0, 1))
Exit Sub
Wend
On Error GoTo 0
Err_Execute:
MsgBox "An error occurred."
End Sub
Bookmarks