I am writing a macro to Copy a range of cells from one sheet to another sheet matching on date values. The code I have so far is:
I ran it once and it worked properly, now it gives me an error on the section:
I have no idea what the issue is, can anyone help please?
Thank you,
Erik
Code:
Sub CopyData()
Dim LDate As String
Dim LRow As Integer
Dim LFound As Boolean
'Retrieve date value to search for
LDate = Sheets("DD Calculator").Range("AX7").Value
Sheets("DD Calculator").Select
'Start at row 1000
LRow = 1000
LFound = False
While LFound = False
If Cells(LRow, 3) = LDate Then
'Select values to copy from "Rolling Plan" sheet
Sheets("DD Calculator").Select
Range("AW11:AW58").Select
Selection.Copy
'Paste onto "Plan" sheet
Sheets("HDDs").Select
Cells(LRow, 14).Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=True
LFound = True
'Continue searching
Else
LRow = LRow + 1
End If
Wend
End Sub
I ran it once and it worked properly, now it gives me an error on the section:
Code:
Else
LRow = LRow + 1
End If
I have no idea what the issue is, can anyone help please?
Thank you,
Erik
Last edited by a moderator: