Results 1 to 4 of 4

Do while loop to delete worksheets if worksheets are not in the specified list

Threaded View

  1. #1
    Registered User
    Join Date
    07-22-2010
    Location
    Singapore
    MS-Off Ver
    Excel 2007
    Posts
    85

    Do while loop to delete worksheets if worksheets are not in the specified list

    Hi,

    I have a list of worksheets on sheet1, i want to perform a do while loop to delete the sheets that are not equals to the sheets in the list so far i have this formula. Can someone help me see where I went wrong

    Sub Delete()
    
    Dim ws As Worksheet
    Dim x As Integer
    
    x = 2
    
    Do While Worksheets("Sheet1").Cells(x, 2) <> ""
        
        For Each ws In ActiveWorkbook
            If ws.Name <> Worksheets("Sheet1").Cells(x, 2) Then
            ws.Delete
            
            End If
        Next ws
        
        x = x + 1
        
    Loop
    
    
    End Sub
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1