copy from a closed Workbook error

KlausW

Active Member
Joined
Sep 9, 2020
Messages
458
Office Version
  1. 2016
Platform
  1. Windows
Hi every one

I'm trying to use this VBA code I found here in the Forum. To copy from a closed Workbook.

But it gets this error message "Object doesn't support this property or method (Error 438)", it could be because the data I want to copy from a closed Workbook has formulas in it. If that's the case, then there are some can help solve the challenge.

Any help will be appreciated

Best Regards

Klaus W

VBA Code:
Sub SkibsNr_Rektangelafrundedehjørner1_Klik()

' Defines variables

Dim wb1 As Workbook, wb2 As Workbook



' Disable screen updating to reduce screen flicker

Application.ScreenUpdating = False



' Define which workbook is which

Set wb1 = ThisWorkbook

Set wb2 = Workbooks.Open("D:\DNBR 2024\Ankomstseddel\Ankomst sedler fastbesætning og VPL\Adresse fastbesætning og VPL.xlsm")



' Copy range A1:W70 from the Data sheet of wb2

wb2.Sheets("SkibsNr").Range("B2:J61").Copy

' Paste the copied data to range A1 of the Data sheet in wb1

wb1.Sheets("SkibsNr").Range("b2").Paste



' Close wb2

wb2.Close



End Sub
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
What happens if you change
VBA Code:
wb2.Sheets("SkibsNr").Range("B2:J61").Copy

' Paste the copied data to range A1 of the Data sheet in wb1

wb1.Sheets("SkibsNr").Range("b2").Paste

to

VBA Code:
wb2.Sheets("SkibsNr").Range("B2:J61").Copy wb1.Sheets("SkibsNr").Range("B2")
 
Upvote 0
What happens if you change
VBA Code:
wb2.Sheets("SkibsNr").Range("B2:J61").Copy

' Paste the copied data to range A1 of the Data sheet in wb1

wb1.Sheets("SkibsNr").Range("b2").Paste

to

VBA Code:
wb2.Sheets("SkibsNr").Range("B2:J61").Copy wb1.Sheets("SkibsNr").Range("B2")
Hi MARK 858 it worked, it asks if I want to save the closed workbook, but I can't remember how to get Excel to skip it so it just closes by itself. Can it copy so its only Value not formula? Klaus W
 
Upvote 0
Can it copy so its only Value not formula?

Yes:

VBA Code:
wb2.Sheets("SkibsNr").Range("B2:J61").Copy
' Paste the copied data to range A1 of the Data sheet in wb1
wb1.Sheets("SkibsNr").Range("b2").PasteSpecial xlPasteValues
 
Upvote 0
Solution
Yes:

VBA Code:
wb2.Sheets("SkibsNr").Range("B2:J61").Copy
' Paste the copied data to range A1 of the Data sheet in wb1
wb1.Sheets("SkibsNr").Range("b2").PasteSpecial xlPasteValues
Hi everyone, thank you very much for your help. Just as it should be. Good day. Best Regards Klaus W
 
Upvote 0

Forum statistics

Threads
1,224,810
Messages
6,181,079
Members
453,021
Latest member
Justyna P

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