+ Reply to Thread
Results 1 to 6 of 6

Insert a new workbook with VBA code in the sheet module into existing macro

  1. #1
    Registered User
    Join Date
    02-06-2009
    Location
    Chattanooga, TN
    MS-Off Ver
    Excel 2007
    Posts
    46

    Insert a new workbook with VBA code in the sheet module into existing macro

    I am trying to figure out how I can insert a new sheet that includes some code that exists in a tab of my current sheet. I have some code that will make each row a specific color based on what is input by the comments column. I want to maintain this functionality in a new sheet where I will copy and paste the data. I have no idea how to do this! I have looked quite a bit online and in the books that I have but I am stumped.

  2. #2
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988

    Re: Insert a new workbook with VBA code in the sheet module into existing macro

    Maybe you could use a
    Please Login or Register  to view this content.
    using a select case or if statement to only run on sheets with similar names. Code would go in ThisWorkbook module

    Also this link may be of interest
    http://www.cpearson.com/excel/vbe.aspx

    VBA Noob
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

  3. #3
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Insert a new workbook with VBA code in the sheet module into existing macro

    Either keep a hidden sheet as a template or copy the existing sheet & delete unneeded data.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  4. #4
    Registered User
    Join Date
    02-06-2009
    Location
    Chattanooga, TN
    MS-Off Ver
    Excel 2007
    Posts
    46

    Re: Insert a new workbook with VBA code in the sheet module into existing macro

    How do I copy the existing sheet? Assuming that I copy the entire existing sheet will that bring over the code as well?

  5. #5
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Insert a new workbook with VBA code in the sheet module into existing macro

    This is the basic code to copy a sheet to the end of existing sheets
    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    02-06-2009
    Location
    Chattanooga, TN
    MS-Off Ver
    Excel 2007
    Posts
    46

    Re: Insert a new workbook with VBA code in the sheet module into existing macro

    I think I am using the wrong term. I need to open a new workbook and insert the code rather then inserting a new sheet. And then I need some code inserted into the new workbooks sheet module.

+ 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