Macro question
Thanks Thanks:  0
Likes Likes:  0
Results 1 to 2 of 2

Thread: Macro question

  1. #1
    New Member
    Join Date
    Mar 2002
    Posts
    6
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

     
    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. #2
    Board Regular
    Join Date
    Mar 2002
    Location
    Houston, TX
    Posts
    60
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

      
    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

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

 

 
DMCA.com