Overkill32
New Member
- Joined
- May 13, 2011
- Messages
- 49
I'm trying to copy values from a workbook to another to create a list. Unfortunitly the run time error identified in the title keeps poping up when the code is asked to paste the range I defined in the other workbook. Here is the code I'm having trouble with. The underlined line is the one where the error keeps coming up.
With Application.FileSearch
.NewSearch
.LookIn = Dirr
.SearchSubFolders = True
.Filename = "file.xls"
.Execute
e = .FoundFiles.Count
End With
If e = 0 Then GoTo Noadds
If e <> 0 Then
Workbooks.Open Filename:=Dirr & "\file.xls", UpdateLinks:=True, ReadOnly:=True
Worksheets("Adds").Select
Range("C1000").End(xlUp).Select
If ActiveCell.Row = 3 Then
Windows("file.xls").Close
GoTo Noadds
End If
NumAdds = ActiveCell.Row
Range("C4:Y" & NumAdds).Copy
Range("C4:Y" & NumAdds).ClearContents
Windows("Masterfile_Adds.xls").Activate
Worksheets("List").Select
Range("C1000").End(xlUp).Select
Oldadds = ActiveCell.Offset(1, 0).Row
ActiveCell.Offset(1, 0).PasteSpecial Paste:=-4163
Range("C1000").End(xlUp).Select
newadds = ActiveCell.Row
For j = Oldadds To newadds
Range("Z" & j).Value = Analyst_Array(i)
Next j
Windows("file.xls").Close
Thanks who whoever can help me!
With Application.FileSearch
.NewSearch
.LookIn = Dirr
.SearchSubFolders = True
.Filename = "file.xls"
.Execute
e = .FoundFiles.Count
End With
If e = 0 Then GoTo Noadds
If e <> 0 Then
Workbooks.Open Filename:=Dirr & "\file.xls", UpdateLinks:=True, ReadOnly:=True
Worksheets("Adds").Select
Range("C1000").End(xlUp).Select
If ActiveCell.Row = 3 Then
Windows("file.xls").Close
GoTo Noadds
End If
NumAdds = ActiveCell.Row
Range("C4:Y" & NumAdds).Copy
Range("C4:Y" & NumAdds).ClearContents
Windows("Masterfile_Adds.xls").Activate
Worksheets("List").Select
Range("C1000").End(xlUp).Select
Oldadds = ActiveCell.Offset(1, 0).Row
ActiveCell.Offset(1, 0).PasteSpecial Paste:=-4163
Range("C1000").End(xlUp).Select
newadds = ActiveCell.Row
For j = Oldadds To newadds
Range("Z" & j).Value = Analyst_Array(i)
Next j
Windows("file.xls").Close
Thanks who whoever can help me!