+ Reply to Thread
Results 1 to 6 of 6

VBA to paste a code snippet in the programatically created new worsheets's module

  1. #1
    Registered User
    Join Date
    06-20-2015
    Location
    Chennai, India
    MS-Off Ver
    2010
    Posts
    59

    VBA to paste a code snippet in the programatically created new worsheets's module

    All,

    I have the below code to paste a code snippet in the programmatically created new worksheet's WORKSHEET (as this code is a worksheet change event)module. But its not working properly, sometimes giving error / sometimes pasting in the previously created sheets. My requirement is, whenever we create a new worksheet using another macro, the worksheet_change event code snippet should be pasted in the newly created worksheet's worksheet module.

    Please Login or Register  to view this content.
    Thanks

  2. #2
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,481

    Re: VBA to paste a code snippet in the programatically created new worsheets's module

    Hi there,

    See if the following code does what you need:

    Please Login or Register  to view this content.

    Hope this helps - please let me know how you get on.

    Regards,

    Greg M

  3. #3
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: VBA to paste a code snippet in the programatically created new worsheets's module

    Try something like this...

    Please Login or Register  to view this content.
    It may be easier to just have a template worksheet with code already in its worksheet code module and just copy it instead of adding a new blank sheet. The template sheet could be hidden if you like.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  4. #4
    Registered User
    Join Date
    06-20-2015
    Location
    Chennai, India
    MS-Off Ver
    2010
    Posts
    59

    Re: VBA to paste a code snippet in the programatically created new worsheets's module

    Thanks a lot Greg & Alpha for your quick answers...

    But thing is once again I am encountering an error only... I think I need to give my "Create sheet" code too to debug n help further.

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    06-20-2015
    Location
    Chennai, India
    MS-Off Ver
    2010
    Posts
    59

    Re: VBA to paste a code snippet in the programatically created new worsheets's module

    HI Alpha,

    Thanks a lot and sorry to disturb you.. You have given the below suggestion... Can you please tell me how should i do that....

    "It may be easier to just have a template worksheet with code already in its worksheet code module and just copy it instead of adding a new blank sheet. The template sheet could be hidden if you like."

    Thanks.

  6. #6
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: VBA to paste a code snippet in the programatically created new worsheets's module

    This copies a hidden worksheet named Template

    Please Login or Register  to view this content.

+ 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. Code snippet working intermittently?!
    By bscdave in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 02-27-2012, 12:34 PM
  2. Better way to write this snippet of code?
    By cooper1308 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-16-2009, 02:16 PM
  3. how to access Sheet module, normal module, Worbook module to type code
    By alibaba in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-31-2009, 07:51 AM
  4. Add sheet. Copy Code & Paste in new Module
    By omnibuster in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-21-2008, 03:37 AM
  5. [SOLVED] Removing Module Protection Programatically
    By Adam in forum Excel General
    Replies: 8
    Last Post: 04-17-2006, 12:46 AM
  6. [SOLVED] Paste doesn't work when module is created
    By Kieranz in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-28-2006, 08:10 AM
  7. Problem in WITH/END WITH code snippet
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-21-2006, 11:10 AM

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