+ Reply to Thread
Results 1 to 5 of 5

Adding sheets with name

Hybrid View

  1. #1
    Registered User
    Join Date
    01-29-2021
    Location
    Delhi
    MS-Off Ver
    2019
    Posts
    2

    Adding sheets with name

    I just started learning about VBA, and got stuck writing a code that uses the form button to:
    1) Creates a new sheet
    2) After the indexed sheet
    3) with a new name

    Here is my code, which seems to be not running:

    Private Sub CommandButton1_Click()
    Sheets.Add(After:=Sheets("day_log")).Name = "Revised"
    adding sheet.png
    Last edited by AliGW; 01-29-2021 at 02:28 AM.

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2504 (Windows 11 Home 24H2 64-bit)
    Posts
    91,031

    Re: Adding sheets with name

    Administrative Note:

    Welcome to the forum.

    We would very much like to help you with your query, however you need to include code tags around your code.

    Please take a moment to add the tags. Posting code between tags makes your code much easier to read and copy for testing, and it also maintains VBA formatting.

    Please see Forum Rule #2 about code tags and adjust accordingly. Click on Edit to open your post, then highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here

    (Note: this change is not optional. As you are new, I have done it for you today.)
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help. It's a universal courtesy.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    NB:
    as a Moderator, I never accept friendship requests.
    Forum Rules (updated August 2023): please read them here.

  3. #3
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    14,958

    Re: Adding sheets with name

    Works as it should...

    Is there a
    End Sub
    to the macro?
    Good Luck...
    I don't presume to know what I am doing, however, just like you, I too started somewhere...
    One-day, One-problem at a time!!!
    If you feel I have helped, please click on the [★ Add Reputation] to left of post window...
    Also....Add a comment if you like!!!!
    And remember...Mark Thread as Solved...
    Excel Forum Rocks!!!

  4. #4
    Registered User
    Join Date
    01-29-2021
    Location
    Delhi
    MS-Off Ver
    2019
    Posts
    2

    Re: Adding sheets with name

    Yes there is at the end

  5. #5
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    14,958

    Re: Adding sheets with name

    What does it not do...Any error msg

+ 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] Codes for Prevent users from adding sheets, deleting sheets, hiding/unhiding sheets
    By geniusufo007 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-13-2017, 11:57 PM
  2. Looking for help adding stuff (noob)
    By Caulnian in forum Excel General
    Replies: 3
    Last Post: 05-21-2015, 01:41 PM
  3. Adding rows to multiple sheets when adding new item using DataForm
    By pandora1a2b in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-11-2014, 01:00 PM
  4. Replies: 3
    Last Post: 07-26-2013, 01:39 AM
  5. Replies: 2
    Last Post: 02-06-2013, 11:25 AM
  6. loop in combobox for adding new sheets when adding new items
    By tnkcoll in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-24-2012, 08:27 PM
  7. Replies: 6
    Last Post: 03-30-2012, 11:25 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