Results 1 to 3 of 3

Thread: Create new tab with a template, locking old one when completed
Thanks Thanks: 0 Likes Likes: 0

  1. #1
    New Member
    Join Date
    Aug 2015
    Posts
    6
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Create new tab with a template, locking old one when completed

    Hi All,

    I am attempting to create an archiving system for work and having some trouble finding a way to do a certain thing because I'm not sure how to word it for the searches...

    So, we have an archiving system, which is a 9 x 9 box for samples (81 samples); on the worksheet so far i have a visual representation of the box using some magical VBA stuff I found years ago, where when an archive position is filled it goes from Red to Green. I have locked the work sheet so only the column with sample ID, Initials of who archived and date can be entered.

    What i would like to do next is when they fill in all 81 spaces, the worksheet locks the tab, to prevent editing without my password, creates a new tab at the front of the worksheet (so the numbers will go in descending order, from the in-use box down to 1, eg 34, 33, 32... 1), with the blank version of the 81 spaces, and automatically renames the tab to the next number (Box 2, Box 3 etc).

    Does anyone know what i can do to make this work?

    Thank you!

  2. #2
    Board Regular
    Join Date
    Nov 2008
    Location
    Netherlands
    Posts
    3,471
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    1 Thread(s)

    Default Re: Create new tab with a template, locking old one when completed

    Hi JonoRig,

    this is fairly simply done.

    I would advise that you make a template sheet of an empty box. You give it a name on the tab , say 'Template'. You can hide this template once it is made.
    Short Guide to Better VBA - Link: https://www.mrexcel.com/forum/showthread.php?t=712119

    Please use code tags around your code:
    [Code] Your code here... [/Code]




    Engelse lessen, persoonlijk en doelgericht. Dutch tuition tailor-made for you. https://Ennef.nl

    Wearable for people with panic attacks: sidjup https://sidjup.com

  3. #3
    Board Regular
    Join Date
    Nov 2008
    Location
    Netherlands
    Posts
    3,471
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    1 Thread(s)

    Default Re: Create new tab with a template, locking old one when completed

    Clicked on the wrong button.

    Before you start adding code etc, create a copy of your live workbook and code in this copy, so you won't screw up your archive! Once done you can move your archived boxes to the coded workbook

    Your code would follow the following steps:

    1. Detect that the last slot is filled
    2. Close the tab
    3. Copy the template
    4. Rename this copy


    Of course this involves a bit of coding.

    1. Detect the last slot is filled
    In essence you would really like to protect each slot once it is filled.
    Then when the last slot is filled the code to make a new box is run.

    To detect changes in a worksheet, you have to create code in the worksheet module.
    Here you can select a worksheet_change sub, where you can check which cell has been changed, and then act on it accordingly

    But to do any real coding, I would need to know the layout of your box sheet. And what is being entered in each cell?/block
    Short Guide to Better VBA - Link: https://www.mrexcel.com/forum/showthread.php?t=712119

    Please use code tags around your code:
    [Code] Your code here... [/Code]




    Engelse lessen, persoonlijk en doelgericht. Dutch tuition tailor-made for you. https://Ennef.nl

    Wearable for people with panic attacks: sidjup https://sidjup.com

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •