Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8782181
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T20:30:29+00:00 2026-06-13T20:30:29+00:00

I am attempting to Copy a specific sheet from a closed workbook to a

  • 0

I am attempting to Copy a specific sheet from a closed workbook to a specific sheet to my opened workbook but I am receiving a run-time error.

The code is below:

Option Explicit

Sub START()


'Defining variables as a worksheet or workbook
Dim shBrandPivot As Worksheet
Dim shCurrentWeek As Worksheet
Dim shPriorWeek As Worksheet
Dim shPivot As Worksheet
Dim wkb As Workbook
Dim wkbFrom As Workbook
Dim wks As Worksheet
Dim rng As Range
Dim path As String, FilePart As String
Dim TheFile
Dim loc As String

'Setting sheets to active or to recognize where to pull information
Set shBrandPivot = ActiveWorkbook.Sheets("Brand Pivot")
Set shCurrentWeek = ActiveWorkbook.Sheets("Current Week")
Set shPriorWeek = ActiveWorkbook.Sheets("Prior Week")
Set shPivot = ActiveWorkbook.Sheets("Pivot")
Set wkb = ThisWorkbook
loc = shPivot.Range("E11").Value
path = shPivot.Range("E12").Value
FilePart = Trim(shPivot.Range("E13").Value)
TheFile = Dir(path & "*" & FilePart & ".xls")
Set wkbFrom = Workbooks.Open(loc & path & TheFile)
Set wks = wkbFrom.Sheets("SUPPLIER_01_00028257_KIK CUSTOM")
Set rng = wks.Range("A2:N500")

'Copy and pastes This week number to last week number
shPivot.Range("E22:E23").Copy shPivot.Range("F22")

'Deletes necessary rows in PriorWeek tab
shPriorWeek.Range("A4:AC1000").Delete

'Copies necessary rows in CurrentWeek tab to PriorWeek tab
shCurrentWeek.Range("A4:AC1000").Copy shPriorWeek.Range("A4")

'Copies range from report generated to share drive and pastes into the current week tab of open order report
rng.Copy wkb.Sheets("Current Week").Range("A4")

'Closes the workbook in the shared drive
wkbFrom.Close False

End Sub

This is what is in cell E11, E12 and E13 respectively:

E11 – S:_Supply Chain\Weekly Rpts Supplier and Buyer\
E12 – 102112
E13 – SUPPLIER_01_00028257_KIK CUSTOM PRODUCTS GAINSVILLE_21-OCT-12.xls

The directory I wish to open the closed workbook is S:_Supply Chain\Weekly Rpts Supplier and Buyer\102112\Supplier_01_00028257_KIK CUSTOM PRODUCTS GAINSVILLE_21-OCT-12.xls

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T20:30:31+00:00Added an answer on June 13, 2026 at 8:30 pm

    I recommend you read this

    Cause

    This problem can occur when you give the workbook a defined name and
    then copy the worksheet several times without first saving and closing
    the workbook

    How to Resolve

    To resolve this problem, save and close the workbook periodically
    while the copy process is occurring

    For a summary of the discussion in the chat

    By setting a breakpoint on Set wkbFrom = Workbooks.Open(loc & path & TheFile)

    We realized that the file name was missing cause Dir(path & "*" & FilePart & ".xls")
    returns the directory without the file name.

    So the solution is to add the file name which is in the cell E13

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm attempting to copy cells, one at a time, from an Excel 2003 (or
I am attempting to copy the contents of an array from one sheet (where
I am attempting to copy data from specific columns in one row, and have
I'm attempting to copy data from three workbooks (one at a time) from the
I am attempting to use COPY FROM STDIN to import data into my table.
When attempting to create a tag of a working copy we receive the error,
I'm attempting to copy an NSString to the pasteboard from within an NSBundle that
I am attempting to copy a local file 'magento.tar.gz' from my local machine to
I am attempting to insert a copy of a row from one table into
I have a DataTable that I am attempting to upload, but I run into

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.