+ Reply to Thread
Results 1 to 10 of 10

VBA Code For Automatically Creating New Worksheet

  1. #1
    Registered User
    Join Date
    07-14-2017
    Location
    London, England
    MS-Off Ver
    2016
    Posts
    15

    VBA Code For Automatically Creating New Worksheet

    Hi there,

    Having a bit of trouble with VBA code for creating a new worksheet. Here's what I'm looking to do:-

    - I have a Master worksheet and want to automatically create a new worksheet every time I input a value into each cell in the range A7:A22.
    - The name of the new worksheet would be the same as the value inputted.
    - The worksheet being created would be a copy of a worksheet called "Template".
    - I've had trouble with the Template worksheet becoming hidden after a new worksheet is created but I want it to remain visible.

    I'm not sure f this needs to be worked into the same VBA code, but I also want the cells in range A7:A22 automatically hyper-linked to the matching worksheet.

    Any help would be greatly appreciated!

  2. #2
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,468

    Re: VBA Code For Automatically Creating New Worksheet

    Try this in the module for the "Master" sheet.

    Please Login or Register  to view this content.
    BSB
    Attached Files Attached Files
    Last edited by BadlySpelledBuoy; 03-14-2021 at 11:23 AM.

  3. #3
    Valued Forum Contributor
    Join Date
    09-30-2018
    Location
    Vlaams Brabant Belgium
    MS-Off Ver
    365
    Posts
    456

    Re: VBA Code For Automatically Creating New Worksheet

    Hi,

    Give this a try

    put the following code in the sheet with the A7:A22 range, code area
    Please Login or Register  to view this content.
    Please be as complete as possible in your asking so it may save use all the time to rework the solution because you didn't give all the requirements. If you have a layout in mind please work it out first so we can adapt our solution to it. Thanks.
    If you have been helped, maybe you could click the *

  4. #4
    Registered User
    Join Date
    07-14-2017
    Location
    London, England
    MS-Off Ver
    2016
    Posts
    15

    Re: VBA Code For Automatically Creating New Worksheet

    Thanks, that's fantastic!

    One issue is that if I delete multiple cells at once, from the range on the master sheet, the attached error message comes up.

    Attachment 723581

    Also, the order of the new sheets created is in reverse i.e. cells A7, A8, A9 are shown in order of A9, A8, A7. Is they was to have them in order created?

    Many thanks

  5. #5
    Registered User
    Join Date
    07-14-2017
    Location
    London, England
    MS-Off Ver
    2016
    Posts
    15

    Re: VBA Code For Automatically Creating New Worksheet

    Quote Originally Posted by BadlySpelledBuoy View Post
    Try this in the module for the "Master" sheet.

    Please Login or Register  to view this content.
    BSB
    Thanks BSB,

    Had a couple of errors come up when running this.

    This with the hyperlink.

    Attachment 723585

    And this when deleting cells from the range

    Attachment 723586

    Many thanks

  6. #6
    Registered User
    Join Date
    07-14-2017
    Location
    London, England
    MS-Off Ver
    2016
    Posts
    15

    Re: VBA Code For Automatically Creating New Worksheet

    Quote Originally Posted by Joske920 View Post
    Hi,

    Give this a try

    put the following code in the sheet with the A7:A22 range, code area
    Please Login or Register  to view this content.
    Thanks, that's fantastic!

    One issue is that if I delete multiple cells at once, from the range on the master sheet, the attached error message comes up.

    Attachment 723587

    Also, the order of the new sheets created is in reverse i.e. cells A7, A8, A9 are shown in order of A9, A8, A7. Is they was to have them in order created?

    Many thanks

  7. #7
    Valued Forum Contributor
    Join Date
    09-30-2018
    Location
    Vlaams Brabant Belgium
    MS-Off Ver
    365
    Posts
    456

    Re: VBA Code For Automatically Creating New Worksheet

    Hi,

    I cant see the attachment 723587

    How did you delete the cells because i have deleted them in diferent ways and dont get a error

  8. #8
    Registered User
    Join Date
    07-14-2017
    Location
    London, England
    MS-Off Ver
    2016
    Posts
    15

    Re: VBA Code For Automatically Creating New Worksheet

    Hi,

    I've tried to attach it again.

    Attachment 723598

    I shift select a few cells on the master sheet (say A7:A9) and then press delete. It comes up " Run-time error '13': Type mismatch " then in the VBA " If Target.Text = vbNullString Then " is highlighted yellow.


    I'm also still struggling to find a way to sort the order of the new sheets.

    Thanks

  9. #9
    Registered User
    Join Date
    07-14-2017
    Location
    London, England
    MS-Off Ver
    2016
    Posts
    15

    Re: VBA Code For Automatically Creating New Worksheet

    Also, if I insert a column within the master worksheet, the same run-time error and highlighted VBA comes up

    Thanks

  10. #10
    Registered User
    Join Date
    07-14-2017
    Location
    London, England
    MS-Off Ver
    2016
    Posts
    15

    Re: VBA Code For Automatically Creating New Worksheet

    Hi all,

    It's now all working!

    I added " If Target.Cells.Count > 1 Then Exit Sub " as the first line and it's resolved all the error issues.

    The worksheet order is also resolved.

    Thank you both for 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. Creating a new worksheet that automatically summarizes data form another worksheet
    By harneet27 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-15-2019, 12:35 PM
  2. VBA code to name the worksheet with quarter end date automatically
    By hyunee in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-22-2016, 09:15 AM
  3. Automatically Creating Workbook Files from Worksheet Data
    By jmervyn in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-02-2015, 09:36 AM
  4. Automatically add worksheet change event code
    By kl_clifford in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-13-2015, 03:28 PM
  5. creating tabbed worksheet automatically
    By mammut89 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 07-04-2008, 12:18 PM
  6. Automatically generate Code for a worksheet created by a macro
    By jthompson in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-30-2008, 06:56 AM
  7. update VBA code automatically when worksheet changes
    By winamd72 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-30-2008, 06:37 AM

Tags for this Thread

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