+ Reply to Thread
Results 1 to 8 of 8

Dynamically creating new sheets when data is added to a column

  1. #1
    Registered User
    Join Date
    07-11-2017
    Location
    Landau
    MS-Off Ver
    2010
    Posts
    47

    Dynamically creating new sheets when data is added to a column

    The following code creates a new sheet with a for every value on the "C" column from the "Zuordnung" sheet and renames the sheet with the contents of the cell.
    However, if I want to make it dynamic, i.e. for a new sheet to be created every time I enter an additional entry in the column, what is the best way to do so?

    Please Login or Register  to view this content.
    Any help would be appreciated!
    Last edited by hegdep; 07-13-2017 at 05:04 AM.

  2. #2
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Dynamically creating new sheets when data is added to a column

    Welcome to the forum

    Put this in sheet module for "Zuordnung"

    (working example in attached file)

    Please Login or Register  to view this content.

    SheetModule.jpg
    Attached Files Attached Files
    Last edited by kev_; 07-11-2017 at 03:52 AM.
    Click *Add Reputation to thank those who helped you. Ask if anything is not clear

  3. #3
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Dynamically creating new sheets when data is added to a column

    Some characters are not allowed within sheet names
    \ / * [ ] : ?

    This is a modified version of the same code that can handle illegal characters without the code failing
    A warning is given and the new sheet is deleted if the name is illegal

    Please Login or Register  to view this content.

    IMPORTANT - please edit post#01 - click on edit post, then select the VBA code text and click on # icon
    (this puts your code in code tags and makes it easier to read etc)
    thanks
    Last edited by kev_; 07-11-2017 at 04:09 AM.

  4. #4
    Registered User
    Join Date
    07-11-2017
    Location
    Landau
    MS-Off Ver
    2010
    Posts
    47

    Re: Dynamically creating new sheets when data is added to a column

    Thanks a ton for your warm welcome and your help!
    The second code though, generates only a new sheet with the name. However, doesn't copy the template.
    I rectified it.

  5. #5
    Registered User
    Join Date
    07-11-2017
    Location
    Landau
    MS-Off Ver
    2010
    Posts
    47

    Re: Dynamically creating new sheets when data is added to a column

    @Kev_

    A follow up question. What if the data I am entering on the column is actually a series of numbers?
    The sheet creation doesn't seem to work with the click and drag feature.
    If I must make it more flexible, how am I to incorporate it?

  6. #6
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Dynamically creating new sheets when data is added to a column

    I will experiment with "click and drag" and post amended code later this morning

    In the meantime, please post the complete "corrected" code (enclosed in code tags) for the benefit of future readers

  7. #7
    Registered User
    Join Date
    07-11-2017
    Location
    Landau
    MS-Off Ver
    2010
    Posts
    47

    Re: Dynamically creating new sheets when data is added to a column

    Okay. My code doesn't seem to work. I thought it did, initially. But, I wouldn't be naming my sheets with these characters. So, isn't a big concern for me.

  8. #8
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Dynamically creating new sheets when data is added to a column

    Here you go

    The tricky bit to understand here is that:
    - where there is only one cell the Target cell is not usually the selected cell (cursor has usually moved to adjacent cell)
    - when you click and drag you are selecting cells whose worksheets already exist - so selected cells contains too many cells
    - the range is set either to the one cell or the selected range and new worksheet(s) created
    - if a sheet name already exists, then it cannot be used again and the not-required sheet is deleted
    - the same bit of code also prevents illegal names being used

    Message strings added to tell user what happened
    - sheets will not have been added for one of 2 reasons (illegal name or already exists)
    - sheet already exists if it's the 2(or more) cells inducing pattern at top of click and drag range - so not a problem
    - sheet already exists if a value in column C is duplicated
    (you may prefer to get rid of the messages)

    (There probably is a way to specify the range for the newly added cells in click and drag (and thus avoid creating and deleting some sheets) but I was too lazy to look it up - the result is the same - I may investigate sometime and let you know )

    Please Login or Register  to view this content.
    or without the messages
    Please Login or Register  to view this content.
    Last edited by kev_; 07-11-2017 at 04:15 PM.

+ 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. [SOLVED] Dynamically changing indirect formulaes when columns are added to sheets.
    By Newbuilder in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 10-22-2016, 02:22 PM
  2. Creating auto populating Summary sheet as new sheets are added to work book
    By Phraedrique in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-18-2012, 05:01 PM
  3. Creating dynamically sheets with data and template
    By Fulla in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-20-2011, 02:40 PM
  4. dynamically added rows
    By johnzm in forum Excel General
    Replies: 6
    Last Post: 05-16-2010, 07:05 AM
  5. creating a subtotal for a dynamically sized column
    By Galoredk in forum Excel General
    Replies: 2
    Last Post: 03-02-2010, 06:22 PM
  6. Can Sheets be Added/Renamed via VBA dynamically thru the Main Sheet- Sheet 1?
    By e4excel in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-27-2009, 08:47 AM
  7. creating pop-up menu from dynamically generated column values
    By bcamp1973 in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-12-2007, 01:11 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