+ Reply to Thread
Results 1 to 6 of 6

Need Help Referencing Sheet Name in a Macro

  1. #1
    Registered User
    Join Date
    09-09-2014
    Location
    Mojave, California
    MS-Off Ver
    MS Office Professional Plus 2013 (excel)
    Posts
    4

    Need Help Referencing Sheet Name in a Macro

    I have a workbook which contains a blank expense report document with a pivot table which summarizes the line item charges by accounting code. I created a macro which would copy the blank document, create a new worksheet and refresh the pivot table database (on the new worksheet) so that it looks to the appropriate columns on the new worksheet for its source data.

    This seemed to work fine, but once I moved the document from my desktop to a production folder, the pivot table would not work. In looking at the code for the macro, I see what the problem is, but I’m not certain how to fix it. The highlighted section of code below references the ‘TEST NEW EXPENSE REPORT TEST.xlsm’ file as it existed on my desktop. Once you move the file to another folder or computer, it can’t work any longer. I’m sure there is some way to replace this pointer with an ‘ActiveWorkbook’ type pointer, but I don’t know how to implement this…can someone help??

    Module1.png

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Need Help Referencing Sheet Name in a Macro

    Hi and welcome to the forum.

    Most of us prefer you to upload the actual workbook for things like this. Pictures are rarely much use (see guidance in the rules area). Upload the workbook and maybe someone will be able to assist.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Registered User
    Join Date
    09-09-2014
    Location
    Mojave, California
    MS-Off Ver
    MS Office Professional Plus 2013 (excel)
    Posts
    4

    Re: Need Help Referencing Sheet Name in a Macro

    Thanks for the pointer! Here is the workbook in question.
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    09-09-2014
    Location
    Mojave, California
    MS-Off Ver
    MS Office Professional Plus 2013 (excel)
    Posts
    4

    Re: Need Help Referencing Sheet Name in a Macro

    Bump - no response

  5. #5
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,260

    Re: Need Help Referencing Sheet Name in a Macro

    To refer to the activeworkbook, you'd need:
    Please Login or Register  to view this content.
    Remember what the dormouse said
    Feed your head

  6. #6
    Registered User
    Join Date
    09-09-2014
    Location
    Mojave, California
    MS-Off Ver
    MS Office Professional Plus 2013 (excel)
    Posts
    4

    Re: Need Help Referencing Sheet Name in a Macro

    Thanks! That worked!

+ 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. Want to run the same macro on multiple worksheets without referencing the sheet name
    By kerrya98 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-11-2013, 05:14 PM
  2. Sort in Macro without referencing specific sheet
    By Ellie1326 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-22-2013, 09:01 AM
  3. Replies: 0
    Last Post: 01-09-2013, 06:58 AM
  4. [SOLVED] Help with renaming a sheet and referencing that sheet in a macro
    By cober123 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-30-2012, 01:18 AM
  5. Macro sheet naming and referencing
    By ConorOB1 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-10-2007, 06:13 AM

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