Macro question

lackeysl

New Member
Joined
Mar 26, 2002
Messages
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.
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
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
 
Upvote 0

Forum statistics

Threads
1,214,415
Messages
6,119,381
Members
448,888
Latest member
Arle8907

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top