Thanks Thanks:  0
Likes Likes:  0
Results 1 to 2 of 2

Thread: Inserting a new sheet w/ a name

  1. #1
    Board Regular
    Join Date
    Feb 2002
    Posts
    117
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    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. #2
    MrExcel MVP Ivan F Moala's Avatar
    Join Date
    Feb 2002
    Location
    Auckland, New Zealand
    Posts
    4,209
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    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

Some videos you may like

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •