I created a code to pull in another excel document of data and I keep getting the error
"Run-time error '1004';
Application-defined or object-defining error"
Here is my code:
Please Login or Register to view this content.
I created a code to pull in another excel document of data and I keep getting the error
"Run-time error '1004';
Application-defined or object-defining error"
Here is my code:
Please Login or Register to view this content.
Try removing the last slash ( \ )
Trevor Shuttleworth - Retired Excel/VBA Consultant
I dream of a better world where chickens can cross the road without having their motives questioned
'Being unapologetic means never having to say you're sorry' John Cooper Clarke
Excel can't open a directory; you need to specify a workbook.
Entia non sunt multiplicanda sine necessitate
I tired removing the \ still didn't work.
What do you mean by specifying a workbook? Isn't that what my code is doing?
No, it's specifying a folder in the R drive.
Ah, and, if that's the file name, you would need to add the file extension, for example, .xlsx
Ah thank you that worked! Ok so when I ran the code it pulled up the file I was referencing instead of like pulling the information into the current excel sheet I had open?
You're code just opens the file. It doesn't move the data anywhere.
What are you trying to do?
I am trying to have the code pull information from one excel doc into the current excel doc my code is in
I added to it and when I click the button to run it, I get an error of "Runtime error '9' Script out of range" Then the debugger highlights the line I have in red below.
Please Login or Register to view this content.
I kind of gathered that ...I am trying to have the code pull information from one excel doc into the current excel doc my code is in
Once you have opened the second workbook, you need to select the data you want, copy it, and paste it somewhere in the first workbook. You could copy whole sheets, one or more ranges on one or more sheets, or whatever.... instead of like pulling the information into the current excel sheet I had open?
You can record a macro while you step through the actions manually. That would give you the basic code but it would probably need some tweaking and tidying up.
Ah, our posts overlapped. Try changingtoPlease Login or Register to view this content.
Please Login or Register to view this content.
hm I am still getting the error
Now the code is working but for only cells 1 and 40, none in between.
Please Login or Register to view this content.
I'm guessing that Sheet1 doesn't exist in one of the workbooks.Runtime error '9' Script out of range
The original line:should work, as should my amended version.Please Login or Register to view this content.
That said, I'm confused if it subsequently works but doesn't copy the right cells.
Cells(1, 40).EntireColumn is the same as saying Range("AN1").EntireColumn, that is, a single column. That's not what the original copy said, nor the suggested change.
The suggested change you gave keep giving me errors as well. That is why I tried doing the way that is on the last code I posted. The sheet is named "Sheet1" so I am confused on why it is not working.
Please post samples of both workbooks with any sensitive data removed.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks