+ Reply to Thread
Results 1 to 6 of 6

Create "X" number of Worksheets based on Cell Value entered

  1. #1
    Registered User
    Join Date
    12-04-2013
    Location
    Melbourne
    MS-Off Ver
    Excel 2007
    Posts
    92

    Create "X" number of Worksheets based on Cell Value entered

    Hi,

    I am trying to create "X" number of copies of a worksheet which already exists depending on the value of the cell in the main page.


    In main page-
    Eg: Number of employees: (value is placed in F20) = 5

    create 5 copies of the worksheet which is named as Details (includes a template) and rename them as Employee 1, Employee 2, .... Employee 5

    Thanks

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,475

    Re: Create "X" number of Worksheets based on Cell Value entered

    This example deletes the sheets before adding sheets again.


    Please Login or Register  to view this content.
    Attached Files Attached Files

  3. #3
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: Create "X" number of Worksheets based on Cell Value entered

    Here is my go at it:

    Please Login or Register  to view this content.

  4. #4
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Create "X" number of Worksheets based on Cell Value entered

    Hi tharindudk

    Welcome to the Forum!!

    It's a bit unclear to me...what's the Worksheet Name of your Template...is it "Details"??
    John

    If you have issues with Code I've provided, I appreciate your feedback.

    In the event Code provided resolves your issue, please mark your Thread as SOLVED.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

  5. #5
    Registered User
    Join Date
    12-04-2013
    Location
    Melbourne
    MS-Off Ver
    Excel 2007
    Posts
    92

    Re: Create "X" number of Worksheets based on Cell Value entered

    Hi, Thanks for the help. It works. Except i donno how to reset it everytime i enter a new value, eg if i had 6 and now want only 5. How do i modify it so it generates that amount of sheets everytime i change the number. Thanks

    Sub createTIPT_copies()

    If CheckBox1.Value = True Then

    Dim rng As Range, cnt As Integer, x, sh As Worksheet
    Set rng = Range("F20")
    cnt = rng
    Application.DisplayAlerts = 0


    For x = 1 To cnt
    Sheets("TIPT").Copy After:=Worksheets(Worksheets.Count)
    ActiveSheet.name = "Site " & x
    Next x
    Sheets(2).Activate

    End If
    End Sub

    Thanks
    Last edited by tharindudk; 12-08-2013 at 09:05 PM. Reason: Patrly solved it

  6. #6
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,475

    Re: Create "X" number of Worksheets based on Cell Value entered

    Your missing three lines of my code, that deletes the sheets. You will have to change the sheet name to TIPT

+ 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] Formula Needed to fill multiple cells with "No" when the word "No" is entered into a cell
    By excelteam777 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 11-09-2013, 05:36 PM
  2. Replies: 10
    Last Post: 07-23-2013, 10:52 PM
  3. Create Macro if any cell under "QUANTITY" Column = 0, then Hide, Multiple Worksheets
    By Spodzemny in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-19-2013, 04:15 PM
  4. [SOLVED] Splitting a Cell based on "/" and adding new Rows based on Part Number Logic
    By NeedForExcel in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 03-30-2013, 10:11 AM
  5. How do i create macro to count number of "Y" or "N" in different worksheets
    By tehseen in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-21-2009, 12:34 PM

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