PDA

View Full Version : Solved: Delete all the tabsheets with their names



ygsunilkumar
09-29-2011, 02:02 AM
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

Bob Phillips
09-29-2011, 02:56 AM
Application.DisplaAlerts = False

For Each sh In Activeworkbook.Worksheets

If sh.Name Like "*profile*" Then

sh.Delete
End If
Next sh

Application.DisplaAlerts = True

ygsunilkumar
09-29-2011, 03:50 AM
Application.DisplaAlerts = False

For Each sh In Activeworkbook.Worksheets

If sh.Name Like "*profile*" Then

sh.Delete
End If
Next sh

Application.DisplaAlerts = True
Hi,

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