+ Reply to Thread
Results 1 to 13 of 13

Create cheet based on cell value - dont alow replication

  1. #1
    Registered User
    Join Date
    07-25-2013
    Location
    Namibia
    MS-Off Ver
    Excel 2010
    Posts
    7

    Create cheet based on cell value - dont alow replication

    Afternoon all,

    I am trying to create a VBA macro that creates a new worksheet in a workbook at the click of a button. The problem I have is that I would like this worksheet to be named after the value (a date) in a certain sell (say A1). Also, I would like the macro to NOT allow two worksheets of the same name (with (1) etc.) to be created, but for the macro simply to take the user to the sheet already created, should they select a date for which a sheet already exists. Finally, once a new sheet has been created, I would like the user to be taken to this sheet.

    While I have figured out the macro to make a new sheet, the naming and the rest of it is proving challenging. Does anyone have any good ideas?

    Thanks in advance!

  2. #2
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 365
    Posts
    8,028

    Re: Create cheet based on cell value - dont alow replication

    Are the values (dates) in column A and how does the user select the value for which a new sheet should be created?

  3. #3
    Registered User
    Join Date
    07-25-2013
    Location
    Namibia
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Create cheet based on cell value - dont alow replication

    Hi Mumps,

    The sheets will be created on an individual basis, based on the date that the user will select from a drop down menu (the value of which is in a single cell only), and a "create" button. They will pick a date, and click create. If there is no sheet for this date, it should create a sheet with the date name (taken from the single cell mentioned above), if the sheet already exists with that name, it should just go to that sheet.

    The drop down menu and all of that is already working, it is just a matter of taking the value from the single cell, and making the sheet.

    Thanks

  4. #4
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 365
    Posts
    8,028

    Re: Create cheet based on cell value - dont alow replication

    Instead of using a button, a Worksheet_Change event will automatically create the sheet upon the selection of the date in A1. Right click the tab for the sheet that contains your date in A1. Click 'View Code' and then paste the macro below in the empty code window that opens up. Close the window to return to your sheet. Select a date in A1. Please let me know if this is what you were looking for.
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    07-25-2013
    Location
    Namibia
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Create cheet based on cell value - dont alow replication

    Thanks for the help. This is very very close to what I want. The problem I now have is that the value in cell A1 is a lookup function, and thus the macro comes up with an error (works great if I just type text in). Is there some way around this?

    Thanks again!

  6. #6
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 365
    Posts
    8,028

    Re: Create cheet based on cell value - dont alow replication

    I'm not sure if I have a solution for you but if I could have a look at your file, it might help. Could you post a copy of your file replacing any confidential information with generic data?

  7. #7
    Registered User
    Join Date
    07-25-2013
    Location
    Namibia
    MS-Off Ver
    Excel 2010
    Posts
    7

    Post Re: Create cheet based on cell value - dont alow replication

    Sorry, I am having problems uploading the sheet. Basically, the cell looks up the number returned by the drop down menu with dates, and picks the relevant date using a vlookup function. It seems that this function is causing the problem, so I was wondering if there was some way of "pasting as value" or some such using VBA?
    Attached Files Attached Files
    Last edited by rowlbrown; 07-26-2013 at 11:40 AM.

  8. #8
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 365
    Posts
    8,028

    Re: Create cheet based on cell value - dont alow replication

    Try the attached file. Choose the date in the drop down list and click the button.
    Attached Files Attached Files

  9. #9
    Registered User
    Join Date
    07-25-2013
    Location
    Namibia
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Create cheet based on cell value - dont alow replication

    Perfect! Thanks so much.

  10. #10
    Registered User
    Join Date
    07-25-2013
    Location
    Namibia
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Create cheet based on cell value - dont alow replication

    Hi again,

    I have changed this code slightly so that it now creates the new sheet from another "template" sheet. The problem I now have is that the new sheet appears at the end of the workbook (i.e. the last in the list of worksheets) and I would like it to appear as the third sheet (or if this isnt possible, the first sheet). I can quite figure this out, so any help would be hugely appreciated.

    Please Login or Register  to view this content.

  11. #11
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 365
    Posts
    8,028

    Re: Create cheet based on cell value - dont alow replication

    Try changing this line:
    Please Login or Register  to view this content.
    to:
    Please Login or Register  to view this content.

  12. #12
    Registered User
    Join Date
    07-25-2013
    Location
    Namibia
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Create cheet based on cell value - dont alow replication

    Perfect, thanks. I knew it must be something like this, just couldn't get the syntax right.

    Much appreciated Mumps.

  13. #13
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 365
    Posts
    8,028

    Re: Create cheet based on cell value - dont alow replication

    My pleasure.

+ 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. sheet and cell replication
    By darzan in forum Excel General
    Replies: 1
    Last Post: 04-06-2011, 02:36 PM
  2. Simple Cell replication
    By windlesham13 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 03-11-2008, 02:45 PM
  3. Automated Cell Replication
    By Dr Stupid in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-30-2007, 09:19 AM
  4. [SOLVED] cell borders that I create dont show on print preview or print
    By scott3435 in forum Excel General
    Replies: 2
    Last Post: 04-05-2006, 09:40 PM
  5. [SOLVED] 2 graphs on 1 single chart cheet
    By Eric Desart in forum Excel Charting & Pivots
    Replies: 5
    Last Post: 01-08-2005, 01:06 AM

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