Run time error 424 object required vba

drop05

Active Member
Joined
Mar 23, 2021
Messages
285
Office Version
  1. 365
Platform
  1. Windows
Hello i am getting a run time error 424 object required

the error is happening at the part of the code where i put a ->
What my code is trying to do is copy and paste values from that range set in the code. The code before that, i have other code that has the user select the copy file and the paste file. The file path text is then put into a cell, the copy one is on d5 and paste one is d7

so instead of doing filepathopen since i have this in different modules i figured that if i had the text of the file path somewhere i can reference it and then use it in all modules and the filepathopen code is only used once where the user selects the copy and paste files
is there a way to fix/edit my code so this error doesnt happen and that it can use that file path text and just do to the sheet asked in that case "Sch C" copy the range then paste it into the other file pastes sch c range?

thank you!

code:

Sub Get_data()

Application.ScreenUpdating = False

copy_wb = ThisWorkbook.Worksheets("File Paths").Range("D5").Value
paste_wb = ThisWorkbook.Worksheets("File Paths").Range("d7").Value

-> copy_wb.Worksheets("Sch C").Range("f12:f13").Copy
paste_wb.Worksheets("Sch C").Range("E11:E12").Offset(, myvalC).PasteSpecial Paste:=xlPasteValues
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
What you are doing there is definitely not gonna work, as you have dicovered via the error.

Are the two workbooks, that were previously selected by the user, still open at this point in the code?
 
Upvote 0
What you are doing there is definitely not gonna work, as you have dicovered via the error.

Are the two workbooks, that were previously selected by the user, still open at this point in the code?
Correct, i understand that it will not work which is causing the error, seeking help on a way to adjust to what I am looking to do, if dont mind
No i had them closed.
 
Upvote 0
You have a few options, from easier to more difficult:

1) Leave the files open until you are done with them
2) Reopen them to be used again
3) Try to work with them as closed

Are any of those options doable?
 
Upvote 0
You have a few options, from easier to more difficult:

1) Leave the files open until you are done with them
2) Reopen them to be used again
3) Try to work with them as closed

Are any of those options doable?
Would prefer the easier route, i dont mind them them being open or opening then closing just dont want to have the user open them over and over
 
Upvote 0
Example of what is stored in D5 and D7?

Ie. is it just the directory path or does it include the excel file names/extentions also?
 
Upvote 0
Here is an example, copy source is D5 and Paste source path is d7
1626993860663.png
 
Upvote 0

Forum statistics

Threads
1,223,243
Messages
6,170,964
Members
452,371
Latest member
Frana

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top