![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Board Regular
Join Date: Feb 2002
Posts: 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 |
|
|
|
|
|
#2 | |
|
MrExcel MVP
Join Date: Feb 2002
Location: Auckland, New Zealand
Posts: 4,209
|
Quote:
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 |
|
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|