Can someone advise what is the mistake in this code. I am having error on bold line. It says;
Error-438: Object doesn't support this property or method.
Error-438: Object doesn't support this property or method.
Code:
Option Explicit
Sub OpenAndCopy()
Dim FolderPath As String
Dim SourceFile As String
Dim TargetWB As String
Dim SourceWB As Workbook
Dim SourceWS As Worksheet
FolderPath = "C:\Users\admin\Downloads\Test"
SourceFile = Dir(FolderPath & "*.xlsx*")
TargetWB = ActiveWorkbook.Name
Set SourceWB = Workbooks.Open(FolderPath & SourceFile)
Set SourceWS = SourceWB.Worksheets("RRSP")
[B]SourceWS.Range("A:P").Copy_[/B]
Workbooks(TargetWB).Sheets("Sheet1").Range ("A1")
End Sub
Last edited by a moderator: