Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 4
Default VBA to delete worksheets

Greetings, all.

Would someone help me write code to for my workbook to delete a worksheet(s)
if I have two empty cells? For example, if I have a date cell AND a job
number cell empty I would need that worksheet deleted.

Any help would be much appreciated.

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...excel/200908/1

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,722
Default VBA to delete worksheets

Perhaps something like this:


Sub DeleteSheets()
Dim ws As Worksheet

For Each ws In ThisWorkbook.Worksheets
'Change ranges as appropriate
If ws.Range("A4") = "" And ws.Range("B4") = "" Then
Application.DisplayAlerts = False
ws.Delete
Application.DisplayAlerts = True
End If
Next
End Sub
--
Best Regards,

Luke M
*Remember to click "yes" if this post helped you!*


"Mark_F via OfficeKB.com" wrote:

Greetings, all.

Would someone help me write code to for my workbook to delete a worksheet(s)
if I have two empty cells? For example, if I have a date cell AND a job
number cell empty I would need that worksheet deleted.

Any help would be much appreciated.

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...excel/200908/1


  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 4
Default VBA to delete worksheets

Thank you, Luke, for your response. I will give it a try!

Luke M wrote:
Perhaps something like this:

Sub DeleteSheets()
Dim ws As Worksheet

For Each ws In ThisWorkbook.Worksheets
'Change ranges as appropriate
If ws.Range("A4") = "" And ws.Range("B4") = "" Then
Application.DisplayAlerts = False
ws.Delete
Application.DisplayAlerts = True
End If
Next
End Sub
Greetings, all.

[quoted text clipped - 3 lines]

Any help would be much appreciated.


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...excel/200908/1

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Marco to Delete Worksheets CM4@FL Excel Discussion (Misc queries) 2 February 27th 09 07:26 PM
How to delete blank worksheets Keep_It_Simple_Stupid Excel Worksheet Functions 1 January 23rd 08 09:35 AM
Delete All Worksheets Apart From Some With Particular Name Dave Excel Discussion (Misc queries) 1 October 31st 07 01:30 AM
I can't delete my worksheets Dillon Excel Discussion (Misc queries) 1 March 5th 07 06:10 PM
Add or Delete Rows in Protected worksheets NH Excel Discussion (Misc queries) 0 March 16th 06 05:15 PM


All times are GMT +1. The time now is 12:53 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"