Consulting

Results 1 to 3 of 3

Thread: Solved: Delete all the tabsheets with their names

  1. #1

    Solved: Delete all the tabsheets with their names

    Hi,

    I want to delete all the tabsheets or workbook names contains "profile".

    For example: If tabname of Sheet1, Sheet3, Sheet4, Sheet6 renamed as "aa profile", "ab profile", "ac profile", "ad profile" respectively.

    Now I want to delete all these sheets. Is there any VBA code for this?. Please help

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    [vba]

    Application.DisplaAlerts = False

    For Each sh In Activeworkbook.Worksheets

    If sh.Name Like "*profile*" Then

    sh.Delete
    End If
    Next sh

    Application.DisplaAlerts = True[/vba]
    ____________________________________________
    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
    Quote Originally Posted by xld
    [vba]

    Application.DisplaAlerts = False

    For Each sh In Activeworkbook.Worksheets

    If sh.Name Like "*profile*" Then

    sh.Delete
    End If
    Next sh

    Application.DisplaAlerts = True[/vba]
    Hi,

    Thanks a lot for the code. Its working perfectly as expected.

Posting Permissions

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