Delete/Add Sheet
Thanks Thanks:  0
Likes Likes:  0
Results 1 to 4 of 4

Thread: Delete/Add Sheet

  1. #1
    Board Regular
    Join Date
    Mar 2002
    Location
    Philippines
    Posts
    55
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

     
    Hi there

    I try to have a macro delete Shhet1 in a workbook (being the active sheet) and add a new one, name it "sheet1" and select cell"A1".
    It works fine, but it always gives me the message "The sheet will be deleted permanently" with the choice of accepting or not.
    Now since this macro is embedded in a long code, it interrupts the running of the operation and requires user input.
    How to avoid??
    Hans

  2. #2
    Board Regular
    Join Date
    Mar 2002
    Location
    Philippines
    Posts
    55
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Sorry, here is the code of that Delete/Add macro

    Sub RenewSheet2()
    '
    ' RenewSheet2 Macro
    ' Macro recorded 4/8/2002 by Hans
    '

    '
    Application.EnableEvents = False
    ActiveWindow.SelectedSheets.Delete
    Sheets.Add
    ActiveSheet.Name = "Sheet1"
    Range("A1").Select
    Application.EnableEvents = True
    End Sub

  3. #3
    MrExcel MVP Jay Petrulis's Avatar
    Join Date
    Mar 2002
    Location
    Chicago, IL USA
    Posts
    2,040
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Hi Hans,

    In your code, also include the line

    Application.DisplayAlerts = False so the message won't pop up.

    Set is back to true at the end of the procedure.

    HTH,
    Jay

  4. #4
    Board Regular
    Join Date
    Mar 2002
    Location
    Philippines
    Posts
    55
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

      
    Jay,
    Problem solved!
    Thanks a lot.
    Hans

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
  •  

 

 
DMCA.com