Consulting

Results 1 to 3 of 3

Thread: Deleting worksheets with specific name ??

  1. #1

    Deleting worksheets with specific name ??

    Hi,

    does somebody know how to search specific Worksheet(s), that has the Name "Diagram1" or "Diagram2" and so on, and delete them / it if they / it exist(s).
    Here is a try of my code.
    Sub Makro1()
    
    Dim s As Worksheet
    
    For Each s In Worksheets
    If s.Name Like "Diagram*" Then
    s.Delete
    End If
    Next s
    
    End Sub
    Last edited by Bob Phillips; 04-08-2016 at 10:22 AM. Reason: Added code tags

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,446
    Location
    Sub Makro1()
    Dim s As Worksheet
        
        Application.DisplayAlerts = False
        
        For Each s In ThisWorkbook.Worksheets
            If s.Name Like "Diagram*" Then s.Delete
        Next s
        
        Application.DisplayAlerts = True
    End Sub
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    Hi xld,

    that works perfect. Thank you

Posting Permissions

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