L
Legacy 93538
Guest
Hi
I have this macro which should loop through a cell range row by row and first determine whether the cell is empty and if it is not copy the value and paste it in to column G in another sheet in the same workbook and everytime it pastes it should paste the data into the a new row in column G. However it keeps bringing up an error when it gets to the line highlighted it red below:
The error is "Application-defined or object-defined error" does anyone know why it keeps causing this error?
Thanks
Jessicaseymour
I have this macro which should loop through a cell range row by row and first determine whether the cell is empty and if it is not copy the value and paste it in to column G in another sheet in the same workbook and everytime it pastes it should paste the data into the a new row in column G. However it keeps bringing up an error when it gets to the line highlighted it red below:
Rich (BB code):
Sub PP3InputRef()
Dim StrFldr As String
Dim PPWB As Workbook
Dim cells As Variant
Dim lNextRow As Long
Application.DisplayAlerts = False
StrFldr = ThisWorkbook.Path
Set PPWB = Workbooks.Open(StrFldr & "\" & "HDE_PPIII_Input_Reference_Table_V1.xlsx")
PPWB.Sheets.Add.Name = ("Input_Reference_Table")
PPWB.Sheets("InputRefapd").Range("A1:Y1").Copy
Destination:=PPWB.Sheets("Input_Reference_Table").Range("A1:Y1")
lNextRow = 2
For Each cells In Range("A1:U644")
If cells.Value <> "" Then cells.Copy Destination:=PPWB.Sheets("Input_Reference_Table").Range(lNextRow, 7)
Next cells
End Sub
The error is "Application-defined or object-defined error" does anyone know why it keeps causing this error?
Thanks
Jessicaseymour