+ Reply to Thread
Results 1 to 3 of 3

CopySameSheetFrmWbs

  1. #1
    Forum Contributor
    Join Date
    12-03-2014
    Location
    India
    MS-Off Ver
    2016 .......
    Posts
    390

    Lightbulb CopySameSheetFrmWbs

    Hi,
    I have following code for copying specific sheet of specific folder in another workbook
    but after running this it search documents in different path not in my given path
    strExtension showing value of C:\Users\lenovo\Documents & provide blank file as output


    Please Login or Register  to view this content.

  2. #2
    Forum Expert
    Join Date
    10-06-2017
    Location
    drevni ruchadlo
    MS-Off Ver
    old
    Posts
    2,153

    Re: CopySameSheetFrmWbs

    Quote Originally Posted by sanjuss2 View Post
    1. ...code for copying specific sheet of specific folder in another workbook
    2. ... after running this it search documents in different path not in my given path strExtension showing value of C:\Users\lenovo\Documents & provide blank file as output
    Ad 1. What you mean ?
    Perhaps: "code for copying a specific sheet from one workbook, placed in a specific folder, to another (new) workbook" ?

    Ad 2. From contextual help of vba:
    "You must specify pathname the first time you call the Dir function, or an error occurs. If you also specify file attributes, pathname must be included. Dir returns the first file name that matches pathname. To get any additional file names that match pathname, call Dir again with no arguments."

    So not
    Please Login or Register  to view this content.
    , but
    Please Login or Register  to view this content.
    , where
    Please Login or Register  to view this content.
    Watch out for the last path separator (marked in red).

    Then
    Please Login or Register  to view this content.
    Ok, but remember, that (from contextual help of vba) "The ChDir statement changes the default directory but not the default drive. For example, if the default drive is C, the following statement changes the default directory on drive D, but C remains the default drive: ChDir 'D:\TMP' ".
    For possible disk change use "ChDrive" statement.

    Then, not:
    Please Login or Register  to view this content.
    , but better
    Please Login or Register  to view this content.
    Then, you have
    Please Login or Register  to view this content.
    ???

    Ad A. Ok - you copy the sheet to the new workbook as the last sheet.

    Ad B.
    Please Login or Register  to view this content.
    Why in this way ? After copying your tab "Grocery" has just become the last tab in the new workbook, so is enough:
    Please Login or Register  to view this content.
    Ad C.
    Please Login or Register  to view this content.
    Ok - I understand that the "Grocery" sheet is not the last sheet of "wbOpen" workbook, but ...

    Ad D. ... but why are you changing the name of the sheet if you do not save changes later ?
    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    12-03-2014
    Location
    India
    MS-Off Ver
    2016 .......
    Posts
    390

    Re: CopySameSheetFrmWbs

    Gr8 & Thanks

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1