worksheets.add - can I add and name a sheet at same time

lezawang

Well-known Member
Joined
Mar 27, 2016
Messages
1,805
Office Version
  1. 2016
Platform
  1. Windows
Hi
I know how to add a sheet using worksheets.add function but I wonder if I can name it as same time. The function syntax does not show any argument for name! Thanks you

Function Add([Before], [After], [Count], [Type]) As Object
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
So you want to do this with a Function.
Not a vba script?

Is that correct?
I know how to write scripts but not so good writing functions
 
Upvote 0
Thanks for your reply. I want to write vba code and my code is this



Sub sheetadd()
Workbooks(1).Worksheets.Add before:=Workbooks(1).Worksheets(Worksheets.Count)
End Sub

My question can I at same time name it? I mean I thought I can pass to add function the name and finish with it. I tried to avoid doing another like

workbooks(1).worksheets(worksheets.count -1).name = "hello"

Thank you again.
 
Upvote 0
Here is how I do it:
Code:
Sub Add_Sheet()
'Modified  10/10/2018  8:44:37 PM  EDT
Sheets.Add(Before:=Sheets(1)).Name = "Susan"
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,275
Messages
6,171,122
Members
452,381
Latest member
Nova88

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