+ Reply to Thread
Results 1 to 8 of 8

VBA to name workbook as worksheet

  1. #1
    Registered User
    Join Date
    05-25-2017
    Location
    manchester, England
    MS-Off Ver
    365 Mac
    Posts
    8

    VBA to name workbook as worksheet

    Thank you for reading my post.

    I am new to VBA and I was wondering if you could advise me or guide me in the right direction.

    I have the below VBA code to copy a worksheet to a new workbook and i was wondering is there a way to add to the code to automatically rename the workbook as the worksheet name when this code is run?


    Please Login or Register  to view this content.
    Last edited by alansidman; 05-25-2017 at 09:41 AM. Reason: code tags added

  2. #2
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    Office 365 ProPlus
    Posts
    5,855

    Re: VBA to name workbook as worksheet

    Here's sample. This will add copied sheet before "Sheet1" of new workbook and saves it in same path/folder as the source workbook.

    Please Login or Register  to view this content.
    ?Progress isn't made by early risers. It's made by lazy men trying to find easier ways to do something.?
    ― Robert A. Heinlein

  3. #3
    Registered User
    Join Date
    05-25-2017
    Location
    manchester, England
    MS-Off Ver
    365 Mac
    Posts
    8

    Re: VBA to name workbook as worksheet

    This piece of code is amazing.

    can I ask if the file is on a Sharepoint site would it also work?

  4. #4
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2403 Win 11 Home 64 Bit
    Posts
    23,811

    Re: VBA to name workbook as worksheet

    Code Tags Added
    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found at http://www.excelforum.com/forum-rule...rum-rules.html



    (I have added them for you today. Please take a few minutes to read all Forum Rules and comply in the future.)
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  5. #5
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    Office 365 ProPlus
    Posts
    5,855

    Re: VBA to name workbook as worksheet

    If you have appropriate credential on the network location/folder it should.

    I assume it's on same local network? If it isn't test it and let me know if you encounter issues.

  6. #6
    Registered User
    Join Date
    05-25-2017
    Location
    manchester, England
    MS-Off Ver
    365 Mac
    Posts
    8

    Re: VBA to name workbook as worksheet

    i have saved the file on the sharepoint site, and re run your amazing code but it doesn't update on the site.

  7. #7
    Registered User
    Join Date
    05-25-2017
    Location
    manchester, England
    MS-Off Ver
    365 Mac
    Posts
    8

    Re: VBA to name workbook as worksheet

    Not sure if it makes a difference that I chosen to open the file in Excel and not in windows to undertake this?

  8. #8
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    Office 365 ProPlus
    Posts
    5,855

    Re: VBA to name workbook as worksheet

    Try changing ThisWorkbook.Path part of the code to something like below. Replace path with your actual sharepoint path.

    Please Login or Register  to view this content.
    Edit:
    If above does not work. It's likely you don't have the elevated permissions. Read detail in link below.
    https://support.microsoft.com/en-gb/...-in-office-365
    Last edited by CK76; 05-25-2017 at 10:28 AM. Reason: See Edit:

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 3
    Last Post: 09-10-2016, 02:17 PM
  2. Replies: 5
    Last Post: 09-25-2015, 10:32 AM
  3. Transfer one worksheet in an excel workbook to another worksheet workbook
    By JASAMMY in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-09-2015, 02:50 PM
  4. Replies: 1
    Last Post: 07-19-2014, 06:28 AM
  5. Replies: 2
    Last Post: 07-16-2014, 12:36 PM
  6. Replies: 2
    Last Post: 05-01-2013, 06:17 AM
  7. Can't copy cells from Worksheet A in Workbook 1 to Worksheet B in Workbook 2
    By exartizo in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-11-2005, 05:52 PM

Tags for this Thread

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