Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
How do I delete all blank sheets in a file using VBA? Thanks in advance for
any answers. |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Try this
Dim sh As Worksheet Application.DisplayAlerts = False For Each sh In ActiveWorkbook.Worksheets If ActiveWorkbook.Worksheets.Count 1 Then If IsEmpty(ActiveSheet.UsedRange) Then sh.Delete End If End If Next sh Application.DisplayAlerts = True -- HTH Bob Phillips (replace somewhere in email address with gmail if mailing direct) "linglc" wrote in message ... How do I delete all blank sheets in a file using VBA? Thanks in advance for any answers. |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Linglc,
Try: '============= Public Sub Tester() Dim SH As Worksheet On Error GoTo XIT Application.DisplayAlerts = False For Each SH In ActiveWorkbook.Worksheets With SH If Application.CountA(.Cells) = 0 Then SH.Delete End If End With Next SH XIT: Application.DisplayAlerts = True End Sub '<<============= --- Regards, Norman "linglc" wrote in message ... How do I delete all blank sheets in a file using VBA? Thanks in advance for any answers. |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
careful you don't (try to) delete them all <vbg
-- HTH Bob Phillips (replace somewhere in email address with gmail if mailing direct) "Norman Jones" wrote in message ... Hi Linglc, Try: '============= Public Sub Tester() Dim SH As Worksheet On Error GoTo XIT Application.DisplayAlerts = False For Each SH In ActiveWorkbook.Worksheets With SH If Application.CountA(.Cells) = 0 Then SH.Delete End If End With Next SH XIT: Application.DisplayAlerts = True End Sub '<<============= --- Regards, Norman "linglc" wrote in message ... How do I delete all blank sheets in a file using VBA? Thanks in advance for any answers. |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Bob,
careful you don't (try to) delete them all <vbg Try my code on an emty workbook! <ebg --- Regards, Norman |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Bob,
Even an emPty one! --- Regards, Norman |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Norman,
I missed your error handler <vbg. I should have done it that way (doh!) -- HTH Bob Phillips (replace somewhere in email address with gmail if mailing direct) "Norman Jones" wrote in message ... Hi Bob, Even an emPty one! --- Regards, Norman |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Need help Taking alot data from one sheet (if not blank) and copying toa list on another sheet. | Excel Worksheet Functions | |||
"BLANK" - need to delete | Excel Worksheet Functions | |||
Delete blank row only if 2 consecutive blank rows | Excel Programming | |||
Delete if blank... | Excel Programming | |||
Macro to look for blank rows in sheet, delete the row and autofit | Excel Programming |