+ Reply to Thread
Results 1 to 7 of 7

beginner....macro to add new sheet to workbook

  1. #1
    Registered User
    Join Date
    11-13-2014
    Location
    Hawaii, USA
    MS-Off Ver
    office 2013
    Posts
    4

    beginner....macro to add new sheet to workbook

    hello all i am a beginner self taught and trying to learn vba, macro, and excel functions

    i have a problem.

    i would like to add a sheet to my workbook. once i add the worksheet to the book i want to name it and then have the name of the worksheet that i just created auto populate on a "master" sheet with all the names that i have added to the workbook. i already have the macro to add the new sheet and prompt to name it and works fine. i just cant figure out how to have it automatically add the name to the "master" sheet.

    i.e. i have a workbook that goes by months; jan, feb, mar. i have jan, feb, mar on my mater sheet already. i want to add apr later on and have apr appear on the master sheet after i create the apr sheet. i know it would be easy to just have all the months in already but this is just an example.

    any help or tips would be greatly appreciated.

    thank you for your time.

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

    Re: beginner....macro to add new sheet to workbook

    Attach a sample workbook. Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and use the paperclip icon to open the upload window.

    View Pic

  3. #3
    Registered User
    Join Date
    11-13-2014
    Location
    Hawaii, USA
    MS-Off Ver
    office 2013
    Posts
    4

    Re: beginner....macro to add new sheet to workbook

    this is the code that i use to add the new sheets. it copies a hidden "month" sheet to the end of the workbook.

    i would like to add or modify the code.

    again this is just an example of what i am trying to do.

    please let me know if there is any other information that would be needed to assist in giving me ideas to write this.


    Sub NewPage()

    Sheets("month").Visible = True
    Sheets("month").Copy After:=Worksheets(Worksheets.Count)
    newpagename = InputBox("Name of month")
    ActiveWindow.ActiveSheet.Name = newpagename
    Sheets("month").Visible = False
    End Sub

  4. #4
    Registered User
    Join Date
    11-13-2014
    Location
    Hawaii, USA
    MS-Off Ver
    office 2013
    Posts
    4

    Re: beginner....macro to add new sheet to workbook

    this is just a sample book that i created.

    thank you davesexcel for your quick response. i look forward to your reply.
    Attached Files Attached Files

  5. #5
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: beginner....macro to add new sheet to workbook

    Hi, danrau,

    please have a look at Forum Rule#3 to understand why you are asked to apply code-tags to your procedure.

    Try
    Please Login or Register  to view this content.
    You would still need to make sure that only legal characters and up to 31 characters would be used. This code enters the name of the sheet directly to the Range A2 of teh new sheet.

    Ciao,
    Holger
    Last edited by HaHoBe; 11-13-2014 at 06:34 AM. Reason: moved code line for visibility of sheet inside the If-Statement
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

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

    Re: beginner....macro to add new sheet to workbook

    Try this.
    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    11-13-2014
    Location
    Hawaii, USA
    MS-Off Ver
    office 2013
    Posts
    4

    Re: beginner....macro to add new sheet to workbook

    Thank you HaHoBe and davesexcel.

    this works like a champ.

    looking at the code i dont know how you did it but i will be dissecting it thoroughly to see what and how this works.

    Great job guys. this forum rocks.

    be well

+ 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. Excel beginner. trying to compile a summary sheet
    By DJP1976 in forum Excel - New Users/Basics
    Replies: 4
    Last Post: 02-04-2014, 09:44 AM
  2. [SOLVED] macro to copy rows from a sheet in one workbook to a sheet in a different workbook...
    By fredderf81 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-16-2013, 01:36 PM
  3. [SOLVED] Beginner Here: I need Macros to transfer specific data from one sheet to another sheet
    By aleem5 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 04-08-2013, 12:36 AM
  4. Beginner help! error no return() or halt() function found on macro sheet
    By steppin16 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-27-2006, 03:10 PM
  5. [SOLVED] RE: macro beginner
    By Rowan in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-28-2005, 10:05 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