+ Reply to Thread
Results 1 to 4 of 4

Add Code To Worksheet with VBA

  1. #1
    Valued Forum Contributor realniceguy5000's Avatar
    Join Date
    03-20-2008
    Location
    Fl
    MS-Off Ver
    Excel 2003 & 2010
    Posts
    951

    Add Code To Worksheet with VBA

    Hi,

    Once again I find myself having to edit some code in around 52 workbooks, each workbook has one sheet. I was able to use this code below to delete the problem worksheet code. However what I want now is to add some code back into the worksheet. I have seen several examples on how to add Mods and placing code into mods and even how to add code into Thisworkbook. but havent found anything about adding in sheet code.

    Anyway does anyone know a way to add a private sub routine into a worksheet?

    Here is what I used to remove the code. Can someone help modify this to add code back in?

    Please Login or Register  to view this content.
    Thanks as always, Mike
    Last edited by realniceguy5000; 07-14-2010 at 12:32 PM.

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

    Re: Add Code To Worksheet with VBA

    If you know how to add code into the ThisWorkbook module, there shouldn't really be much difference adding it to a worksheet module.
    The fact that you are having to do this repeatedly suggests to me you might want to rethink whatever it is that you are doing...
    Remember what the dormouse said
    Feed your head

  3. #3
    Valued Forum Contributor realniceguy5000's Avatar
    Join Date
    03-20-2008
    Location
    Fl
    MS-Off Ver
    Excel 2003 & 2010
    Posts
    951

    Re: Add Code To Worksheet with VBA

    Quote Originally Posted by romperstomper View Post
    If you know how to add code into the ThisWorkbook module, there shouldn't really be much difference adding it to a worksheet module.
    The fact that you are having to do this repeatedly suggests to me you might want to rethink whatever it is that you are doing...
    Understood, I'll work on some type of code and do some experimenting. This normally happens once a year since I create these workbooks.worksheets from last years templates from the previous year. I'm now working on 2011 workbooks for the year so that is why the change occurs. I just don't want to recreate the workbooks again is all.

    I'll keep looking. Thank You,

  4. #4
    Valued Forum Contributor realniceguy5000's Avatar
    Join Date
    03-20-2008
    Location
    Fl
    MS-Off Ver
    Excel 2003 & 2010
    Posts
    951

    Re: Add Code To Worksheet with VBA

    Quote Originally Posted by romperstomper View Post
    If you know how to add code into the ThisWorkbook module, there shouldn't really be much difference adding it to a worksheet module.
    The fact that you are having to do this repeatedly suggests to me you might want to rethink whatever it is that you are doing...
    This wasn't so Hard After All.

    Here is a solution should anyone find the need...

    This will loop though all workbooks in a folder and delete the current procedure name and add the same procedure back with new code.

    Please Login or Register  to view this content.
    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)

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