ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Delete Tab Formula Problem (https://www.excelbanter.com/excel-programming/330956-delete-tab-formula-problem.html)

greengrass[_2_]

Delete Tab Formula Problem
 

I am having problem with the following code. A member was nice of
enough to provide the following:

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

I thought using searchs and such I would be able to figure out how to
make this work, wrong, so here I am looking for some again.

What I am trying to do is delete unsed worksheets in a single workbook.
The workbook has 20 worksheets but not all sheets are used all the time
and I would like to delete the extra sheets. All sheets have same
number of rows, columns, so, if cell f286 = 0 delete sheet and go to
next sheet etc.

Any help for this newbie would be great!

Thanks,


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


Didier Poskin

Delete Tab Formula Problem
 
Hi,

I guess you could try this :
Sub DeleteTabs()
On Error Resume Next
Application.DisplayAlerts = False

For Each x In Worksheets
If x.cells(286,6)=0 Then x.Delete 'this tests cell F286
Next x

Application.DisplayAlerts = True

End Sub

Cheers,

Didier



greengrass[_3_]

Delete Tab Formula Problem
 

Thank you very much, the adjustments provided do what I need

--
greengras
-----------------------------------------------------------------------
greengrass's Profile: http://www.excelforum.com/member.php...fo&userid=2311
View this thread: http://www.excelforum.com/showthread.php?threadid=37657



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

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