How to create a macro to add a new worksheet and rename it.

mridul.trehan

New Member
Joined
Aug 2, 2009
Messages
10
I tried recording a macro to add to a new worksheet, but it gives error while running.

Issue as I understand is, by default excel gives a new worksheet a name (Say Sheet 4), and when u run macro worksheet, new created name may be different.
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
Alternatively:

Code:
Sub fff()

    With Sheets.Add
        .Name = "my sheet"
        .[A1] = "blah blah blah"
        .Move after:=Sheets(Sheets.Count)
    End With

End Sub
 
Upvote 0
Let me confess, I am too lazy!

I have created a macro which along with other things delete and creates a sheet.

Now when I run the macro, it asks for confirmation before deletion, which means I (or someone else) have to be present to click yes for that to move forward.

Can I skip that??
 
Upvote 0
Try this:
<CODE></CODE>
<CODE><CODE>
Code:
 Application.DisplayAlerts=false
</CODE></CODE>
 
Last edited:
Upvote 0
Hi, I am new to this but a quick learner!
I need to have many users press a button within the excel sheet that duplicates the form from the current page, opening a new tab (copying the form) that also prompts to input a specific name e.g. "Enter date and day or night shift" to name the tab itself.
I have just worked out how to put a Command Button in and used the above code to create the new page assigning the code to it.
I need the "my sheet" to be prompted and customisable.
Hope this makes sense.
 
Upvote 0

Forum statistics

Threads
1,213,528
Messages
6,114,154
Members
448,553
Latest member
slaytonpa

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top