+ Reply to Thread
Results 1 to 3 of 3

Macro creating new worksheet and connecting table to newly created worksheet

  1. #1
    Registered User
    Join Date
    12-08-2022
    Location
    St. Louis, MO
    MS-Off Ver
    Version 2202
    Posts
    1

    Macro creating new worksheet and connecting table to newly created worksheet

    I want to create a macro that creates a new worksheet based on a filled out template, clears the template for future use, and then adds the information to a larger table (on the first worksheet) by referencing the newly created worksheet. The problem I am having is that the macro will work the first time, but then instead of adding information to the larger table based on the newly created worksheet, it will pull from the worksheet that was created the first time. Any help is greatly appreciated! Thank you!
    Attached Files Attached Files

  2. #2
    Registered User
    Join Date
    08-24-2022
    Location
    hugo
    MS-Off Ver
    13
    Posts
    40

    Re: Macro creating new worksheet and connecting table to newly created worksheet

    hello, I did not test this code but maybe this can help?
    To make sure your macro always references the correct worksheet, you will need to fully qualify the worksheet references in your code. This means that, whenever you reference a worksheet or range in your code, you should include the workbook and worksheet name, as well as the cell or range reference. For example, instead of using Range("A1"), you would use something like ThisWorkbook.Worksheets("Sheet1").Range("A1"). This tells Excel to use the range "A1" on the "Sheet1" worksheet in the active workbook.

    Another approach you could use is to create a variable to store a reference to the new worksheet. You could then use this variable throughout your code to reference the correct worksheet. For example:
    Please Login or Register  to view this content.
    By using a variable to store the reference to the new worksheet, you can avoid any confusion about which worksheet your code is referencing.

  3. #3
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,541

    Re: Macro creating new worksheet and connecting table to newly created worksheet

    This tells Excel to use the range "A1" on the "Sheet1" worksheet in the active workbook.
    Strictly speaking, this tells Excel to use the range "A1" on the "Sheet1" worksheet in the workbook with the code in it, which may, or may not, be the active workbook.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


+ 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. [SOLVED] Copy a link from a newly created worksheet back to Overview worksheet
    By nigelog in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-20-2019, 06:32 AM
  2. macro code to activate the newly created worksheet in excel.
    By Shellybelly in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-15-2015, 05:55 PM
  3. Linking newly created worksheet names to cells?
    By qstillso in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 06-23-2015, 07:09 AM
  4. [SOLVED] Use Current Worksheet Name in Formula to Rename Newly Created Worksheet
    By MICowboy13 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-12-2015, 04:26 PM
  5. Updating data on newly created worksheet
    By wolverine82 in forum Excel General
    Replies: 6
    Last Post: 04-14-2010, 11:17 AM
  6. macro that will automatically link a newly created worksheet to a summary sheet
    By liquidblack in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-18-2009, 03:22 PM
  7. [SOLVED] Referencing a newly created worksheet
    By Charyn in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 05-02-2005, 12:07 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