Inserting a new sheet w/ a name

Todd_M

Board Regular
Joined
Feb 24, 2002
Messages
117
Hi-
I have a userform with a textbox and a commandbutton. The user puts text into the textbox and presses the commandbutton. I want a new sheet to be created with the name that the user placed in the textbox. Besides the code sheets.add, how do you name the sheet from the textbox.text? However I do not want this sheet to show!! It will be called from another userform if the user wishes to do so. Thanks- Todd
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
On 2002-03-19 18:07, Todd_M wrote:
Hi-
I have a userform with a textbox and a commandbutton. The user puts text into the textbox and presses the commandbutton. I want a new sheet to be created with the name that the user placed in the textbox. Besides the code sheets.add, how do you name the sheet from the textbox.text? However I do not want this sheet to show!! It will be called from another userform if the user wishes to do so. Thanks- Todd

try

Private Sub CommandButton1_Click()
Dim ShCount As Double

ShCount = ActiveWorkbook.Sheets.Count
On Error GoTo AddShErr
ActiveWorkbook.Sheets.Add().Name = TextBox1.Text
ActiveSheet.Visible = False
Exit Sub
AddShErr:
If ShCount < ActiveWorkbook.Sheets.Count Then
Application.DisplayAlerts = False
ActiveSheet.Delete
Application.DisplayAlerts = True
End If
MsgBox Err.Number & vbCr & _
Err.Description
End Sub



Ivan
 
Upvote 0

Forum statistics

Threads
1,214,653
Messages
6,120,750
Members
448,989
Latest member
mariah3

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