+ Reply to Thread
Results 1 to 3 of 3

Dynamically add vba code to a sheet

  1. #1
    Registered User
    Join Date
    09-04-2006
    Posts
    29

    Dynamically add vba code to a sheet

    Hi,

    I need to add code to a custom sheet when it is created via a macro. For example i create a sheet named "Sheet 3" and i need to add code to the pre definied procedure SelectionChange associated with "Sheet 3". Can anyone help me with this???

    Thanks

  2. #2
    Valued Forum Contributor Excelenator's Avatar
    Join Date
    07-25-2006
    Location
    Wantagh, NY
    Posts
    333
    One way to do this would be to "create" the new sheet by copying a sheet that you have already set up and includes the code you are looking to include.
    ---------------------------------------------------
    ONLY APPLIES TO VBA RESPONSES WHERE APPROPRIATE
    To insert code into the VBE (Visual Basic Editor)
    1. Copy the code.
    2. Open workbook to paste code into.
    3. Right click any worksheet tab, select View Code
    4. VBE (Visual Basic Editor) opens to that sheets object
    5. You may change to another sheets object or the This Workbook object by double clicking it in the Project window
    6. In the blank space below the word "General" paste the copied code.

  3. #3
    Forum Contributor
    Join Date
    08-27-2006
    Posts
    136
    Appears this was cross posted.
    http://www.excelforum.com/showthread.php?t=575234

    See here for why not to do so, and how to indicate this when you do.
    http://www.excelguru.ca/node/7

+ 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