LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Deleting Sheet with No Data

Help I have been trying to automate the Deletion of sheets with NO
data. All of my worksheets have Column Headers in Row-1. What I need
to do is scroll through the worksheets (about 15-20) and Delete the
sheet if there is no data in Column-X (starting in Row-2). I had the
following but for some reasoon it is not working. I think I am having
a brain-freeze. Any help would be appreciated.

Sub MainMacro()
'
Dim MyString, MyString2 As String
Dim MyWorksheet As String

Range("A1").Select
MyString = "EXTVCML"
MyWorksheet = "Extvcml"
BlankTestMacro MyString, MyWorksheet
MyString = "FAX"
MyWorksheet = "FAX"
BlankTestMacro MyString, MyWorksheet
End Sub
Sub BlankTestMacro(MyString, MyWorksheet)
'
Const SAVESTR As String = "MyString"
Dim myRange As Range
Dim cell As Range
Dim delRange As Range

Sheets(MyWorksheet).Select
ActiveWindow.WindowState = xlMaximized
Columns("A:BZ").Select
Selection.Sort Key1:=Range("X2"), Order1:=xlDescending,
Key2:=Range("Z2") _
, Order2:=xlAscending, Key3:=Range("A2"), Order3:=xlAscending,
Header:= _
xlYes, OrderCustom:=1, MatchCase:=False,
Orientation:=xlTopToBottom
Columns("X:X").Select
On Error Resume Next
Selection.Find(What:=SAVESTR, After:=ActiveCell,
LookIn:=xlFormulas, LookAt _
:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:= _
False).Activate
If Err.Number < 91 And Err.Number < 0 Then
MsgBox "Unresolved Error"
Exit Sub
End If
Range("X2").Select
If ActiveCell.Cells = isblank Then
'If Column x IS Blank
ActiveWindow.SelectedSheets.Delete
Exit Sub
End If
If ActiveCell.Row < 0 Then
If Not delRange Is Nothing Then Columns("B:B").Delete
Else
'If Column x is NOT Blank
End If
End Sub

 
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
Deleting cell data without deleting formula Tom Hall Excel Discussion (Misc queries) 4 October 29th 06 04:07 PM
sub for deleting data on a sheet in a range Buddy Lee Excel Programming 3 September 20th 05 09:14 PM
Deleting sheet Brandi[_2_] Excel Programming 2 October 7th 04 09:31 PM
Deleting a sheet P. Dileepan[_2_] Excel Programming 3 April 12th 04 10:34 AM
Deleting a Sheet Abdul Salam Excel Programming 1 July 29th 03 12:43 AM


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

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"