ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Remove unwanted tabs (https://www.excelbanter.com/excel-programming/330443-remove-unwanted-tabs.html)

greengrass

Remove unwanted tabs
 

Can someone please provide me with a procedure to delete unused tabs.

I have a workbook that has 20 tabs containing pricing and material
numbers. When the users fills out information it is usually only on
one tab and I would like a macro function to automatically delete the
other 19 sheets to reduce the size of the file.

Thanks,

GG


--
greengrass
------------------------------------------------------------------------
greengrass's Profile: http://www.excelforum.com/member.php...o&userid=23119
View this thread: http://www.excelforum.com/showthread...hreadid=374981


JMB

Remove unwanted tabs
 
I think this will do what you need. Back up your workbook before trying it
out.

Sub DeleteTabs()
On Error Resume Next
Application.DisplayAlerts = False

For Each x In Worksheets
If IsEmpty(x.UsedRange) Then x.Delete
Next x

Application.DisplayAlerts = True

End Sub

"greengrass" wrote:


Can someone please provide me with a procedure to delete unused tabs.

I have a workbook that has 20 tabs containing pricing and material
numbers. When the users fills out information it is usually only on
one tab and I would like a macro function to automatically delete the
other 19 sheets to reduce the size of the file.

Thanks,

GG


--
greengrass
------------------------------------------------------------------------
greengrass's Profile: http://www.excelforum.com/member.php...o&userid=23119
View this thread: http://www.excelforum.com/showthread...hreadid=374981




All times are GMT +1. The time now is 10:10 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com