vba - copy form one workbook to another doesnt work

GlobaLevel
GlobaLevel used Ask the Experts™
on
I am try to copy a range from one workbook to another...but it is not working for me...even though not every cell will have a value....
Dim newXl As Object
Dim wbk As Workbook
Dim ws As Worksheet
Dim strCopy As String
Dim csvPath As String
Dim dcCopyBefore As String
Dim strArray As String


dcCopyBefore = "dcCopyBefore.csv"
  
'Create a directoriy to save new copy of CB Data to
MyPath = "C:\disputedChangesRpts"
If Dir$(MyPath, vbDirectory) = "" Then MkDir MyPath
    
Set newXl = Workbooks.Add
    With newXl
        .Title = "dcCopyBefore"
        .Subject = "dcCopyBefore"
        .SaveAs Filename:="C:\disputedChangesRpts\dcCopyBefore.csv"
    End With
'ActiveWorkbook.Close



Workbooks("dcCopyBefore.csv").Sheets("Sheet1").Range("A6:K65000") = Workbooks("DisputedCharges - Back office interface -v15.xls").Sheets("Disputed Charges").Range("G6:Q65000")

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Most Valuable Expert 2011
Top Expert 2011

Commented:
What do you mean when you say it's not working? What is happening?
Top Expert 2010

Commented:
Hello GlobaLevel,

Please explain what you mean by "not working."

Regards,

Patrick
Top Expert 2015
Commented:
Two questions.
1. Are you runnihg this code from worbook-->"DisputedCharges - Back office interface -v15.xls"
2. Try this line and see do you get any error in that.
Workbooks("dcCopyBefore.csv").Sheets("Sheet1").Range("A6:K65000") .Copy  Workbooks("DisputedCharges - Back office interface -v15.xls").Sheets("Disputed Charges").Range("G6:Q65000")
If yes then whats the error message you get..?
Saurabh

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial