+ Reply to Thread
Results 1 to 5 of 5

Automaticly delete extra sheet

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    02-11-2009
    Location
    Salt Lake City, Utah
    MS-Off Ver
    Excel 365
    Posts
    100

    Automaticly delete extra sheet

    Shouldn't be to hard, I would think. I just don't have the know-how.
    I'm looking for how to get the code to automatically delete a sheet I don't need anymore. No popup asking for confirmation.

    Currently the following code creates a popup declaring "there might be information on the other sheet, are you sure you want to delete?"

    Sheets("Tab").Delete
    Full code is here

    Sub Worksheet_Change(ByVal Target As Range)
    Dim v As Double
    
    Set t = Target
    Set r = Range("K1")
    If Intersect(t, r) Is Nothing Then
    Exit Sub
    Else
    v = Val(r.Value)
    End If
        Select Case v
            Case 1
                Range("A2").Copy
                Range("A2").PasteSpecial Paste:=xlPasteValues, Operation _
                    :=xlNone, SkipBlanks:=False, Transpose:=False
                Range("H7:H9").Copy
                Range("H7:H9").PasteSpecial Paste:=xlPasteValues, Operation _
                    :=xlNone, SkipBlanks:=False, Transpose:=False
                Sheets("Tab").Delete
        End Select
    End Sub
    Last edited by timmtamm; 04-06-2011 at 05:07 PM.

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    45,150

    Re: Automaticly delete extra sheet

    Application.DisplayAlerts = False
    Sheets("Tab").Delete
    Application.DisplayAlerts = True

    Regards
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,318

    Re: Automaticly delete extra sheet

    Try...

    Application.EnableEvents = False
    Sheets("Tab").Delete
    Application.EnableEvents = True
    HTH
    Regards, Jeff

  4. #4
    Forum Contributor
    Join Date
    02-11-2009
    Location
    Salt Lake City, Utah
    MS-Off Ver
    Excel 365
    Posts
    100

    Re: Automaticly delete extra sheet

    Thanks! That works perfectly.

  5. #5
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,318

    Re: Automaticly delete extra sheet

    Glad it worked for you

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1