Hello Friends
Could you please check why am I getting error message "Script out of Range" for the following code for copying and pasting the data to another workbook?
The code works upto the line highlighted in blue and then gives the error message.
I am using this code in another bigger code.
Thanks for your help
Rajesh
Could you please check why am I getting error message "Script out of Range" for the following code for copying and pasting the data to another workbook?
Code:
Sub CreateWorkBook()
Dim i As Long
Dim strPath As String
strPath = "C:\Rajesh\"
For i = 1 To 10
[Color=blue]Workbooks.Add.SaveAs (strPath & "Load" & i) [/Color]
ThisWorkbook.Sheets("DataSheet").Range("A1,G20").Copy Workbooks(strPath & "Load" & i & ".xlsx") _
.Sheets(1).Range("A1")
Next i
End Sub
The code works upto the line highlighted in blue and then gives the error message.
I am using this code in another bigger code.
Thanks for your help
Rajesh