![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
New Member
Join Date: Mar 2002
Posts: 6
|
I have a form that has multiple sheets. Each time the form is used, not all sheets are needed. I would like to write a macro that would delete any sheets that do not have data in cell L1 prior to saving.
|
|
|
|
|
|
#2 |
|
Board Regular
Join Date: Mar 2002
Location: Houston, TX
Posts: 60
|
This should work, or at least be a start:
Private Sub DeleteSheets() Dim wkb As Workbook Dim wks As Worksheet Set wkb = Application.ActiveWorkbook For Each wks In wkb.Worksheets If wks.Range("L1") = "" Then wks.Delete End If Next wks Set wks = Nothing Set wkb = Nothing End Sub |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|