+ Reply to Thread
Results 1 to 5 of 5

Can vba be used to move code to a new workbook?

  1. #1
    Registered User
    Join Date
    11-24-2007
    Location
    Florida
    MS-Off Ver
    Various
    Posts
    64

    Can vba be used to move code to a new workbook?

    Hello

    I have a code to create a new workbook. I would like to add a Worksheet_SelectionChange code to one of the created worksheets.

    Is it possible to automate this during the vba create process?

    Thanks

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,644

    Re: Can vba be used to move code to a new workbook?

    You could write code to create code but it might be easier to have a template worksheet with the SelectionChange code in it and copy that to the new workbook.
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    11-24-2007
    Location
    Florida
    MS-Off Ver
    Various
    Posts
    64

    Re: Can vba be used to move code to a new workbook?

    The reason I'm asking is because I will be using a code to make lots of workbooks. I was hoping I could automate the process of copying a bit of code so I wouldn't have to do it hundreds of times.

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,644

    Re: Can vba be used to move code to a new workbook?

    Yes you can do it, but it would be easier to work with a template worksheet no matter how many workbooks you are creating.

    For example to create a new workbook and copy a template worksheet to it:
    Please Login or Register  to view this content.
    To add the SelectionChange event to a worksheet in a newly created workbook using code:
    Please Login or Register  to view this content.
    That's a very simple example and only creates code for a message box.

  5. #5
    Registered User
    Join Date
    11-24-2007
    Location
    Florida
    MS-Off Ver
    Various
    Posts
    64

    Re: Can vba be used to move code to a new workbook?

    Excellent. Now I have something to play with. I really appreciate your help.

+ 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. VBA Code to Copy and Move Closed Workbook
    By kozman2 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-23-2013, 09:36 AM
  2. Move ranges from workbook to workbook based on cell value
    By SLIDE1 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 10-05-2012, 10:45 PM
  3. Cut and move data by macro (?) from one workbook to master workbook
    By esylvester in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-17-2012, 02:57 AM
  4. Move Data from One Workbook into mulitple sheets in another Workbook
    By charmingpri in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-30-2010, 01:09 AM
  5. Code creates new workbook-> code to automatically run a set code on that workbook
    By cwalker6 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-20-2009, 08:00 PM

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