Results 1 to 2 of 2

Thread: Worksheets Delete Macro From Master List

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1

    Worksheets Delete Macro From Master List

    Hi All,

    I am trying to delete some worksheets within a workbook from a list containing the names of worksheets to be deleted, listed in column B2:B30, in sheet titled " Sheetlist". I obtained the following code from a thread, the code seems to work if column B in the specified range are all populated. If it is empty, as in the example, the code does no work.

    In "SheetList" sheet, cell A2 onwards in column A contain all the names within the workbook. Cell B2 onwards in column B to cell B30 will be the area which I specify the sheets I need to delete.

    Can you please help to modify the code so that the macro will loop through each cell from B2:B30 eventhough it is empty, and delete worksheets name which are listed?



    Sub DeleteSheets()
    Dim i As Long
    For i = 2 To 30

    Application.DisplayAlerts = False
    Worksheets(CStr(ActiveSheet.Cells(i, 2).Value)).Delete
    Application.DisplayAlerts = True
    Next i
    End Sub

    Attached Files Attached Files

Posting Permissions

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